Skip to content

Commit 919da92

Browse files
author
Robert Jackson
committed
Fix subject name detection for moduleFor('type:name').
Previously, when no `options` were detected the `subject` was not set, causing issues later when we try to process `this.subject()` statements.
1 parent 9c81b0f commit 919da92

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

__testfixtures__/ember-qunit-codemod/subject.input.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,9 @@ moduleFor('service:foo', 'Unit | Service | Foo', {
7777
test('can use service', function (assert) {
7878
this.service.something();
7979
});
80+
81+
moduleFor('service:foo');
82+
83+
test('does not require more than one argument', function(assert) {
84+
let suject = this.subject();
85+
});

__testfixtures__/ember-qunit-codemod/subject.output.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,11 @@ module('Unit | Service | Foo', function(hooks) {
8282
this.service.something();
8383
});
8484
});
85+
86+
module('service:foo', function(hooks) {
87+
setupTest(hooks);
88+
89+
test('does not require more than one argument', function(assert) {
90+
let subject = this.owner.factoryFor('component:foo-bar').create();
91+
});
92+
});

ember-qunit-codemod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module.exports = function(file, api, options) {
110110
if (lastArgument.type === 'ObjectExpression') {
111111
options = calleeArguments.pop();
112112
}
113-
moduleName = calleeArguments[1] || calleeArguments[0];
113+
subject = moduleName = calleeArguments[1] || calleeArguments[0];
114114

115115
let setupIdentifier = 'setupTest';
116116
if (options) {

0 commit comments

Comments
 (0)