Skip to content

Commit aadfc70

Browse files
author
Robert Jackson
committed
Ensure setupRenderingTest tests are async functions.
1 parent 7ea50d1 commit aadfc70

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

__testfixtures__/ember-qunit-codemod/module-for-component.output.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import hbs from 'htmlbars-inline-precompile';
55
module('Integration | Component | FooBar', function(hooks) {
66
setupRenderingTest(hooks);
77

8-
test('it happens', function() {
8+
test('it happens', async function() {
99
this.render(hbs`derp`);
1010
});
1111
});

ember-qunit-codemod.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,22 +150,30 @@ function updateModuleForToNestedModule(j, root) {
150150
});
151151
}
152152

153-
return [moduleInvocation, callback.body.body];
153+
return [moduleInvocation, callback.body.body, setupType];
154154
}
155155

156156
let programPath = root.get('program');
157157
let bodyPath = programPath.get('body');
158158

159159
let bodyReplacement = [];
160-
let currentModuleCallbackBody;
160+
let currentModuleCallbackBody, currentTestType;
161161
bodyPath.each(expressionPath => {
162162
let expression = expressionPath.node;
163163
if (isModuleDefinition(expressionPath)) {
164164
let result = createModule(expressionPath);
165165
bodyReplacement.push(result[0]);
166166
currentModuleCallbackBody = result[1];
167+
currentTestType = result[2];
167168
} else if (currentModuleCallbackBody) {
168169
currentModuleCallbackBody.push(expression);
170+
171+
if (currentTestType === 'setupRenderingTest') {
172+
let isTest = j.match(expression, { expression: { callee: { name: 'test' } } });
173+
if (isTest) {
174+
expression.expression.arguments[1].async = true;
175+
}
176+
}
169177
} else {
170178
bodyReplacement.push(expression);
171179
}

0 commit comments

Comments
 (0)