Skip to content

Commit edae547

Browse files
committed
Convert moduleFor to module
1 parent 9b342f4 commit edae547

File tree

5 files changed

+97
-90
lines changed

5 files changed

+97
-90
lines changed
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
import { moduleForComponent } from 'ember-qunit';
1+
import { module } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import '@ember/test-helpers';
24
import test from 'ember-sinon-qunit/test-support/test';
35
import assertSinonInTestContext from '../../helpers/assert-sinon-in-test-context';
46

57
const fooValue = 42;
68

7-
moduleForComponent(
8-
'video-player',
9-
'Deprecated | Integration | Component | video player',
10-
{
11-
integration: true,
12-
beforeEach() {
13-
this.foo = fooValue;
14-
},
15-
}
16-
);
9+
module('Deprecated | Integration | Component | video player', function (hooks) {
10+
setupRenderingTest(hooks);
1711

18-
assertSinonInTestContext(test);
12+
hooks.beforeEach(function () {
13+
this.foo = fooValue;
14+
});
1915

20-
test('preserving the context from the `beforeEach` hook', function (assert) {
21-
assert.equal(this.foo, fooValue);
16+
assertSinonInTestContext(test);
17+
18+
test('preserving the context from the `beforeEach` hook', function (assert) {
19+
assert.equal(this.foo, fooValue);
20+
});
2221
});

‎tests/unit/ember-sinon-qunit-test.js

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -9,72 +9,72 @@ let fooValue = 42;
99
let origMethod;
1010
let obj;
1111

12-
module('Deprecated | Unit | ember-sinon-qunit', {
13-
beforeEach() {
12+
module('Deprecated | Unit | ember-sinon-qunit', function (hooks) {
13+
hooks.beforeEach(function () {
1414
this.foo = fooValue;
1515

1616
origMethod = () => {};
1717
obj = {
1818
method: origMethod,
1919
};
20-
},
20+
});
2121

22-
afterEach(assert) {
22+
hooks.afterEach(function (assert) {
2323
assert.equal(obj.method, origMethod, 'stub was reset');
24-
},
25-
});
24+
});
2625

27-
assertSinonInTestContext(test);
26+
assertSinonInTestContext(test);
2827

29-
const deprecateStub = sinon
30-
.stub(Ember, 'deprecate')
31-
.callsFake(function (unused, deprecateTest) {
32-
if (deprecateTest !== false) {
33-
throw new Error(
34-
'Ember.deprecate should be called with 2nd argument `false`'
35-
);
36-
}
37-
});
28+
const deprecateStub = sinon
29+
.stub(Ember, 'deprecate')
30+
.callsFake(function (unused, deprecateTest) {
31+
if (deprecateTest !== false) {
32+
throw new Error(
33+
'Ember.deprecate should be called with 2nd argument `false`'
34+
);
35+
}
36+
});
3837

39-
test('does not destroy context from beforeEach', function (assert) {
40-
assert.equal(this.foo, fooValue);
41-
});
38+
test('does not destroy context from beforeEach', function (assert) {
39+
assert.equal(this.foo, fooValue);
40+
});
4241

43-
if (!deprecateStub.called) {
44-
throw new Error('Ember.deprecate should be called');
45-
}
46-
deprecateStub.restore();
42+
if (!deprecateStub.called) {
43+
throw new Error('Ember.deprecate should be called');
44+
}
45+
deprecateStub.restore();
4746

48-
test('async with assert.async()', function (assert) {
49-
assert.expect(2);
50-
this.stub(obj, 'method');
47+
test('async with assert.async()', function (assert) {
48+
assert.expect(2);
49+
this.stub(obj, 'method');
5150

52-
const done = assert.async();
53-
setTimeout(() => {
54-
assert.notEqual(obj.method, origMethod, 'stub not reset yet');
55-
done();
51+
const done = assert.async();
52+
setTimeout(() => {
53+
assert.notEqual(obj.method, origMethod, 'stub not reset yet');
54+
done();
55+
});
5656
});
57-
});
5857

59-
test('async with Promise', function (assert) {
60-
assert.expect(2);
61-
this.stub(obj, 'method');
58+
test('async with Promise', function (assert) {
59+
assert.expect(2);
60+
this.stub(obj, 'method');
6261

63-
return resolve().then(() => {
64-
assert.notEqual(obj.method, origMethod);
62+
return resolve().then(() => {
63+
assert.notEqual(obj.method, origMethod);
64+
});
6565
});
66-
});
6766

68-
test('async with Promise and assert.async()', function (assert) {
69-
assert.expect(3);
70-
this.stub(obj, 'method');
67+
test('async with Promise and assert.async()', function (assert) {
68+
assert.expect(3);
69+
this.stub(obj, 'method');
7170

72-
return resolve().then(() => {
73-
assert.notEqual(obj.method, origMethod, 'stub not reset yet');
74-
const done = assert.async();
75-
setTimeout(() => {
71+
return resolve().then(() => {
7672
assert.notEqual(obj.method, origMethod, 'stub not reset yet');
77-
done();
73+
const done = assert.async();
74+
setTimeout(() => {
75+
assert.notEqual(obj.method, origMethod, 'stub not reset yet');
76+
done();
77+
});
7878
});
7979
});
8080
});

‎tests/unit/models/only-test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { module } from 'qunit';
22
import test from 'ember-sinon-qunit/test-support/test';
33
import only from 'ember-sinon-qunit/test-support/only';
44

5-
module('Deprecated | Unit | Utils | only');
6-
7-
test('can import only', function (assert) {
8-
assert.equal(typeof only, 'function', 'can import `only');
5+
module('Deprecated | Unit | Utils | only', function () {
6+
test('can import only', function (assert) {
7+
assert.equal(typeof only, 'function', 'can import `only');
8+
});
99
});

‎tests/unit/models/user-test.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
1-
import { moduleForModel } from 'ember-qunit';
1+
import { module } from 'qunit';
2+
import { setupTest } from 'ember-qunit';
23
import test from 'ember-sinon-qunit/test-support/test';
34
import assertSinonInTestContext from '../../helpers/assert-sinon-in-test-context';
45

6+
import { run } from '@ember/runloop';
7+
58
const fooValue = 42;
69

7-
moduleForModel('user', 'Deprecated | Unit | Model | user', {
8-
integration: true,
9-
beforeEach() {
10+
module('Deprecated | Unit | Model | user', function (hooks) {
11+
setupTest(hooks);
12+
13+
hooks.beforeEach(function () {
1014
this.foo = fooValue;
11-
},
12-
});
15+
});
1316

14-
test('it exists', function (assert) {
15-
let model = this.subject();
16-
// let store = this.store();
17-
assert.ok(!!model);
18-
});
17+
test('it exists', function (assert) {
18+
let model = run(() =>
19+
this.owner.lookup('service:store').createRecord('user')
20+
);
21+
// let store = this.store();
22+
assert.ok(!!model);
23+
});
1924

20-
assertSinonInTestContext(test);
25+
assertSinonInTestContext(test);
2126

22-
test('preserving the context from the `beforeEach` hook', function (assert) {
23-
assert.equal(this.foo, fooValue);
27+
test('preserving the context from the `beforeEach` hook', function (assert) {
28+
assert.equal(this.foo, fooValue);
29+
});
2430
});

‎tests/unit/routes/application-test.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
import { moduleFor } from 'ember-qunit';
1+
import { module } from 'qunit';
2+
import { setupTest } from 'ember-qunit';
23
import test from 'ember-sinon-qunit/test-support/test';
34
import assertSinonInTestContext from '../../helpers/assert-sinon-in-test-context';
45

56
const fooValue = 42;
67

7-
moduleFor('route:application', 'Deprecated | Unit | Route | application', {
8-
integration: true,
9-
beforeEach() {
8+
module('Deprecated | Unit | Route | application', function (hooks) {
9+
setupTest(hooks);
10+
11+
hooks.beforeEach(function () {
1012
this.foo = fooValue;
11-
},
12-
});
13+
});
1314

14-
test('it exists', function (assert) {
15-
let route = this.subject();
16-
assert.ok(route);
17-
});
15+
test('it exists', function (assert) {
16+
let route = this.owner.lookup('route:application');
17+
assert.ok(route);
18+
});
1819

19-
assertSinonInTestContext(test);
20+
assertSinonInTestContext(test);
2021

21-
test('preserving the context from the `beforeEach` hook', function (assert) {
22-
assert.equal(this.foo, fooValue);
22+
test('preserving the context from the `beforeEach` hook', function (assert) {
23+
assert.equal(this.foo, fooValue);
24+
});
2325
});

0 commit comments

Comments
 (0)