Skip to content

Commit 668d7d7

Browse files
committed
Update test suite
1 parent aa1a318 commit 668d7d7

File tree

4 files changed

+157
-157
lines changed

4 files changed

+157
-157
lines changed

tests/unit/mixins/adaptable-test.js

Lines changed: 108 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { module, test } from 'qunit';
99

1010
let sandbox, adapters;
1111

12-
module('Unit | Mixin | adaptable', {
13-
beforeEach() {
12+
module('Unit | Mixin | adaptable', function(hooks) {
13+
hooks.beforeEach(function() {
1414
sandbox = Sinon.sandbox.create();
1515
adapters = {
1616
starships: [
@@ -28,157 +28,157 @@ module('Unit | Mixin | adaptable', {
2828
}
2929
]
3030
};
31-
},
31+
});
3232

33-
afterEach() {
33+
hooks.afterEach(function() {
3434
sandbox.restore();
35-
}
36-
});
37-
38-
test('it initialises the adapters object', function(assert) {
39-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
40-
let subject = AdaptableObject.create();
41-
42-
assert.deepEqual(get(subject, '_adapters'), {});
43-
});
35+
});
4436

45-
test('it initialises the context object', function(assert) {
46-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
47-
let subject = AdaptableObject.create();
37+
test('it initialises the adapters object', function(assert) {
38+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
39+
let subject = AdaptableObject.create();
4840

49-
assert.deepEqual(get(subject, 'context'), {});
50-
});
41+
assert.deepEqual(get(subject, '_adapters'), {});
42+
});
5143

52-
test('it registers configured adapters', function(assert) {
53-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
54-
let subject = AdaptableObject.create();
44+
test('it initialises the context object', function(assert) {
45+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
46+
let subject = AdaptableObject.create();
5547

56-
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
57-
return Starship; // Return a non-instantiated adapter.
58-
})
48+
assert.deepEqual(get(subject, 'context'), {});
49+
});
5950

60-
subject.activateAdapters(adapters.starships);
61-
assert.ok(subject);
62-
});
51+
test('it registers configured adapters', function(assert) {
52+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
53+
let subject = AdaptableObject.create();
6354

64-
test('it passes config options to the configured adapters', function(assert) {
65-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
66-
let subject = AdaptableObject.create();
55+
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
56+
return Starship; // Return a non-instantiated adapter.
57+
})
6758

68-
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
69-
return Starship; // Return a non-instantiated adapter.
59+
subject.activateAdapters(adapters.starships);
60+
assert.ok(subject);
7061
});
7162

72-
subject.activateAdapters(adapters.starships);
73-
assert.equal(get(subject, '_adapters.Enterprise.config.captain'), 'Jean-Luc Picard');
74-
});
75-
76-
test('#invoke invokes the named method on activated adapters', function(assert) {
77-
assert.expect(6);
63+
test('it passes config options to the configured adapters', function(assert) {
64+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
65+
let subject = AdaptableObject.create();
7866

79-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
80-
let subject = AdaptableObject.create();
67+
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
68+
return Starship; // Return a non-instantiated adapter.
69+
});
8170

82-
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
83-
return Starship; // Return a non-instantiated adapter.
71+
subject.activateAdapters(adapters.starships);
72+
assert.equal(get(subject, '_adapters.Enterprise.config.captain'), 'Jean-Luc Picard');
8473
});
8574

86-
subject.activateAdapters(adapters.starships);
75+
test('#invoke invokes the named method on activated adapters', function(assert) {
76+
assert.expect(6);
8777

88-
const EnterpriseStub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
89-
const VoyagerStub = sandbox.stub(get(subject, '_adapters.Voyager'), '_makeItSo');
78+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
79+
let subject = AdaptableObject.create();
9080

91-
const EnterpriseSpy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
92-
const VoyagerSpy = sandbox.spy(get(subject, '_adapters.Voyager'), 'warp');
81+
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
82+
return Starship; // Return a non-instantiated adapter.
83+
});
9384

94-
const warpFactor = {
95-
factor: 8
96-
};
85+
subject.activateAdapters(adapters.starships);
9786

98-
subject.invoke('warp', warpFactor);
87+
const EnterpriseStub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
88+
const VoyagerStub = sandbox.stub(get(subject, '_adapters.Voyager'), '_makeItSo');
9989

100-
assert.ok(EnterpriseSpy.calledOnce);
101-
assert.ok(EnterpriseSpy.calledWith(warpFactor));
102-
assert.ok(EnterpriseStub.calledOnce);
90+
const EnterpriseSpy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
91+
const VoyagerSpy = sandbox.spy(get(subject, '_adapters.Voyager'), 'warp');
10392

104-
assert.ok(VoyagerSpy.calledOnce);
105-
assert.ok(VoyagerSpy.calledWith(warpFactor));
106-
assert.ok(VoyagerStub.calledOnce);
107-
});
93+
const warpFactor = {
94+
factor: 8
95+
};
10896

109-
test('#invoke invokes the named method on a single activated adapter', function(assert) {
110-
assert.expect(3);
97+
subject.invoke('warp', warpFactor);
11198

112-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
113-
let subject = AdaptableObject.create();
99+
assert.ok(EnterpriseSpy.calledOnce);
100+
assert.ok(EnterpriseSpy.calledWith(warpFactor));
101+
assert.ok(EnterpriseStub.calledOnce);
114102

115-
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
116-
return Starship; // Return a non-instantiated adapter.
103+
assert.ok(VoyagerSpy.calledOnce);
104+
assert.ok(VoyagerSpy.calledWith(warpFactor));
105+
assert.ok(VoyagerStub.calledOnce);
117106
});
118107

119-
subject.activateAdapters(adapters.starships);
108+
test('#invoke invokes the named method on a single activated adapter', function(assert) {
109+
assert.expect(3);
120110

121-
const stub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
122-
const spy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
111+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
112+
let subject = AdaptableObject.create();
123113

124-
const warpFactor = {
125-
factor: 8
126-
};
114+
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
115+
return Starship; // Return a non-instantiated adapter.
116+
});
127117

128-
subject.invoke('warp', 'Enterprise', warpFactor);
118+
subject.activateAdapters(adapters.starships);
129119

130-
assert.ok(spy.calledOnce);
131-
assert.ok(spy.calledWith(warpFactor));
132-
assert.ok(stub.calledOnce);
133-
});
120+
const stub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
121+
const spy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
134122

135-
test('#invoke includes `context` properties', function(assert) {
136-
assert.expect(3);
123+
const warpFactor = {
124+
factor: 8
125+
};
137126

138-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
139-
let subject = AdaptableObject.create();
127+
subject.invoke('warp', 'Enterprise', warpFactor);
140128

141-
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
142-
return Starship; // Return a non-instantiated adapter.
129+
assert.ok(spy.calledOnce);
130+
assert.ok(spy.calledWith(warpFactor));
131+
assert.ok(stub.calledOnce);
143132
});
144133

145-
subject.activateAdapters(adapters.starships);
134+
test('#invoke includes `context` properties', function(assert) {
135+
assert.expect(3);
146136

147-
const stub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
148-
const spy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
137+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
138+
let subject = AdaptableObject.create();
149139

150-
const warpFactor = {
151-
factor: 8
152-
};
140+
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
141+
return Starship; // Return a non-instantiated adapter.
142+
});
153143

154-
set(subject, 'context.warpCapabilities', true);
155-
subject.invoke('warp', 'Enterprise', warpFactor);
144+
subject.activateAdapters(adapters.starships);
156145

157-
assert.ok(spy.calledOnce);
158-
assert.ok(spy.calledWith({ warpCapabilities: true, factor: 8 }));
159-
assert.ok(stub.calledOnce);
160-
});
146+
const stub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
147+
const spy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
161148

162-
test('#invoke does not leak options between calls', function(assert) {
163-
assert.expect(3);
149+
const warpFactor = {
150+
factor: 8
151+
};
164152

165-
let AdaptableObject = EmberObject.extend(AdaptableMixin);
166-
let subject = AdaptableObject.create();
153+
set(subject, 'context.warpCapabilities', true);
154+
subject.invoke('warp', 'Enterprise', warpFactor);
167155

168-
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
169-
return Starship; // Return a non-instantiated adapter.
156+
assert.ok(spy.calledOnce);
157+
assert.ok(spy.calledWith({ warpCapabilities: true, factor: 8 }));
158+
assert.ok(stub.calledOnce);
170159
});
171160

172-
subject.activateAdapters(adapters.starships);
161+
test('#invoke does not leak options between calls', function(assert) {
162+
assert.expect(3);
163+
164+
let AdaptableObject = EmberObject.extend(AdaptableMixin);
165+
let subject = AdaptableObject.create();
166+
167+
sandbox.stub(subject, '_lookupAdapter').callsFake(function() {
168+
return Starship; // Return a non-instantiated adapter.
169+
});
173170

174-
const stub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
175-
const spy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
171+
subject.activateAdapters(adapters.starships);
176172

177-
set(subject, 'context.warpCapabilities', true);
178-
subject.invoke('warp', 'Enterprise', { factor: 8, callOne: true });
179-
subject.invoke('warp', 'Enterprise', { factor: 8, callTwo: true });
173+
const stub = sandbox.stub(get(subject, '_adapters.Enterprise'), '_makeItSo');
174+
const spy = sandbox.spy(get(subject, '_adapters.Enterprise'), 'warp');
180175

181-
assert.ok(spy.called);
182-
assert.ok(spy.calledWith({ warpCapabilities: true, factor: 8, callTwo: true }));
183-
assert.ok(stub.called);
176+
set(subject, 'context.warpCapabilities', true);
177+
subject.invoke('warp', 'Enterprise', { factor: 8, callOne: true });
178+
subject.invoke('warp', 'Enterprise', { factor: 8, callTwo: true });
179+
180+
assert.ok(spy.called);
181+
assert.ok(spy.calledWith({ warpCapabilities: true, factor: 8, callTwo: true }));
182+
assert.ok(stub.called);
183+
});
184184
});

tests/unit/utils/proxy-to-adapter-test.js

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,31 @@ import proxyToAdapter from 'dummy/utils/proxy-to-adapter';
66
import { Promise, resolve } from 'rsvp';
77
import { module, test } from 'qunit';
88

9-
module('Unit | Utility | proxy to adapter');
10-
11-
test('it throws an exception if a method name is not specified', function(assert) {
12-
assert.throws(function() {
13-
proxyToAdapter();
9+
module('Unit | Utility | proxy to adapter', function() {
10+
test('it throws an exception if a method name is not specified', function(assert) {
11+
assert.throws(function() {
12+
proxyToAdapter();
13+
});
1414
});
15-
});
1615

17-
test('it returns a resolved promise wrapping the response from invoke', function(assert) {
18-
const AdaptableObject = EmberObject.extend({
19-
invoke: resolve,
20-
doSomething: proxyToAdapter('doSomething')
16+
test('it returns a resolved promise wrapping the response from invoke', function(assert) {
17+
const AdaptableObject = EmberObject.extend({
18+
invoke: resolve,
19+
doSomething: proxyToAdapter('doSomething')
20+
});
21+
22+
let subject = AdaptableObject.create();
23+
assert.ok(subject.doSomething() instanceof Promise);
2124
});
2225

23-
let subject = AdaptableObject.create();
24-
assert.ok(subject.doSomething() instanceof Promise);
25-
});
26+
test('it throws an exception when missing invoke function', function(assert) {
27+
const UnadaptableObject = EmberObject.extend({
28+
doSomething: proxyToAdapter('doSomething')
29+
});
2630

27-
test('it throws an exception when missing invoke function', function(assert) {
28-
const UnadaptableObject = EmberObject.extend({
29-
doSomething: proxyToAdapter('doSomething')
31+
let subject = UnadaptableObject.create();
32+
assert.throws(function() {
33+
subject.doSomething();
34+
}, EmberError);
3035
});
31-
32-
let subject = UnadaptableObject.create();
33-
assert.throws(function() {
34-
subject.doSomething();
35-
}, EmberError);
3636
});

tests/unit/utils/required-method-test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import requiredMethod from 'dummy/utils/required-method';
55

66
import { module, test } from 'qunit';
77

8-
module('Unit | Utility | required method');
9-
10-
test('it throws an exception if a method name is not specified', function(assert) {
11-
assert.throws(function() {
12-
requiredMethod();
8+
module('Unit | Utility | required method', function() {
9+
test('it throws an exception if a method name is not specified', function(assert) {
10+
assert.throws(function() {
11+
requiredMethod();
12+
});
1313
});
14-
});
1514

16-
test('it throws an exception for missing method', function(assert) {
17-
const AdaptableObject = EmberObject.extend({
18-
missingMethod: requiredMethod('missingMethod')
19-
});
15+
test('it throws an exception for missing method', function(assert) {
16+
const AdaptableObject = EmberObject.extend({
17+
missingMethod: requiredMethod('missingMethod')
18+
});
2019

21-
let subject = AdaptableObject.create();
22-
assert.throws(function() {
23-
subject.missingMethod();
24-
}, EmberError, /missingMethod/);
20+
let subject = AdaptableObject.create();
21+
assert.throws(function() {
22+
subject.missingMethod();
23+
}, EmberError, /missingMethod/);
24+
});
2525
});

tests/unit/utils/required-property-test.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ import requiredProperty from 'dummy/utils/required-property';
66
import { get } from '@ember/object';
77
import { module, test } from 'qunit';
88

9-
module('Unit | Utility | required property');
10-
11-
test('it throws an exception if a property name is not specified', function(assert) {
12-
assert.throws(function() {
13-
requiredProperty();
9+
module('Unit | Utility | required property', function() {
10+
test('it throws an exception if a property name is not specified', function(assert) {
11+
assert.throws(function() {
12+
requiredProperty();
13+
});
1414
});
15-
});
1615

17-
test('it throws an exception for missing property', function(assert) {
18-
const AdaptableObject = EmberObject.extend({
19-
missingProperty: requiredProperty('missingProperty')
20-
});
16+
test('it throws an exception for missing property', function(assert) {
17+
const AdaptableObject = EmberObject.extend({
18+
missingProperty: requiredProperty('missingProperty')
19+
});
2120

22-
let subject = AdaptableObject.create();
23-
assert.throws(function() {
24-
get(subject, 'missingProperty');
25-
}, EmberError, /missingProperty/);
21+
let subject = AdaptableObject.create();
22+
assert.throws(function() {
23+
get(subject, 'missingProperty');
24+
}, EmberError, /missingProperty/);
25+
});
2626
});

0 commit comments

Comments
 (0)