Skip to content

Commit a91c167

Browse files
committed
Codemod: ember-qunit-codemod
1 parent 7d5c445 commit a91c167

File tree

2 files changed

+150
-150
lines changed

2 files changed

+150
-150
lines changed

tests/unit/mixin-test.js

Lines changed: 143 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -6,207 +6,207 @@ import {
66
test
77
} from 'qunit';
88

9-
module('ember-buffered-proxy/mixin');
9+
module('ember-buffered-proxy/mixin', function() {
10+
test('that it works', (assert) => {
11+
const BufferedProxy = ObjectProxy.extend(Mixin);
12+
const content = { baz: 1 };
1013

11-
test('that it works', (assert) => {
12-
const BufferedProxy = ObjectProxy.extend(Mixin);
13-
const content = { baz: 1 };
14+
const proxy = BufferedProxy.create({ content });
1415

15-
const proxy = BufferedProxy.create({ content });
16+
assert.equal(get(proxy, 'baz'), 1);
17+
assert.equal(get(content, 'baz'), 1);
1618

17-
assert.equal(get(proxy, 'baz'), 1);
18-
assert.equal(get(content, 'baz'), 1);
19+
assert.ok(!('foo' in content));
20+
assert.equal(get(proxy, 'hasBufferedChanges'), false);
1921

20-
assert.ok(!('foo' in content));
21-
assert.equal(get(proxy, 'hasBufferedChanges'), false);
22+
set(proxy, 'foo', 1);
2223

23-
set(proxy, 'foo', 1);
24+
assert.equal(get(proxy, 'foo'), 1);
25+
assert.ok(!('foo' in content));
26+
assert.equal(get(proxy, 'hasBufferedChanges'), true);
2427

25-
assert.equal(get(proxy, 'foo'), 1);
26-
assert.ok(!('foo' in content));
27-
assert.equal(get(proxy, 'hasBufferedChanges'), true);
28+
proxy.applyBufferedChanges();
2829

29-
proxy.applyBufferedChanges();
30+
assert.equal(get(proxy, 'foo'), 1);
31+
assert.ok('foo' in content);
32+
assert.equal(get(proxy, 'hasBufferedChanges'), false);
33+
assert.equal(get(content, 'foo'), 1);
3034

31-
assert.equal(get(proxy, 'foo'), 1);
32-
assert.ok('foo' in content);
33-
assert.equal(get(proxy, 'hasBufferedChanges'), false);
34-
assert.equal(get(content, 'foo'), 1);
35+
set(proxy, 'bar', 1);
3536

36-
set(proxy, 'bar', 1);
37+
assert.equal(get(proxy, 'foo'), 1);
38+
assert.equal(get(proxy, 'bar'), 1);
3739

38-
assert.equal(get(proxy, 'foo'), 1);
39-
assert.equal(get(proxy, 'bar'), 1);
40+
assert.ok('foo' in content);
41+
assert.ok(!('bar' in content));
4042

41-
assert.ok('foo' in content);
42-
assert.ok(!('bar' in content));
43+
assert.equal(get(proxy, 'hasBufferedChanges'), true);
4344

44-
assert.equal(get(proxy, 'hasBufferedChanges'), true);
45+
proxy.discardBufferedChanges();
4546

46-
proxy.discardBufferedChanges();
47+
assert.equal(get(proxy, 'foo'), 1);
48+
assert.equal(get(proxy, 'bar'), undefined);
4749

48-
assert.equal(get(proxy, 'foo'), 1);
49-
assert.equal(get(proxy, 'bar'), undefined);
50+
assert.ok('foo' in content);
51+
assert.ok(!('bar' in content));
5052

51-
assert.ok('foo' in content);
52-
assert.ok(!('bar' in content));
53+
assert.equal(get(proxy, 'hasBufferedChanges'), false);
5354

54-
assert.equal(get(proxy, 'hasBufferedChanges'), false);
55+
assert.equal(get(proxy, 'baz'), 1);
56+
assert.equal(get(content, 'baz'), 1);
57+
});
5558

56-
assert.equal(get(proxy, 'baz'), 1);
57-
assert.equal(get(content, 'baz'), 1);
58-
});
59+
test('that apply/discard only these keys works', (assert) => {
60+
const BufferedProxy = ObjectProxy.extend(Mixin);
61+
const content = { baz: 1, world: 'hello' };
5962

60-
test('that apply/discard only these keys works', (assert) => {
61-
const BufferedProxy = ObjectProxy.extend(Mixin);
62-
const content = { baz: 1, world: 'hello' };
63+
const proxy = BufferedProxy.create({ content });
6364

64-
const proxy = BufferedProxy.create({ content });
65+
assert.equal(get(proxy, 'baz'), 1);
66+
assert.equal(get(content, 'baz'), 1);
67+
assert.equal(get(proxy, 'world'), 'hello');
68+
assert.equal(get(content, 'world'), 'hello');
6569

66-
assert.equal(get(proxy, 'baz'), 1);
67-
assert.equal(get(content, 'baz'), 1);
68-
assert.equal(get(proxy, 'world'), 'hello');
69-
assert.equal(get(content, 'world'), 'hello');
70+
assert.ok(!('foo' in content));
71+
assert.equal(get(proxy, 'hasBufferedChanges'), false);
7072

71-
assert.ok(!('foo' in content));
72-
assert.equal(get(proxy, 'hasBufferedChanges'), false);
73+
set(proxy, 'foo', 1);
7374

74-
set(proxy, 'foo', 1);
75+
assert.equal(get(proxy, 'foo'), 1);
76+
assert.ok(!('foo' in content));
77+
assert.equal(get(proxy, 'hasBufferedChanges'), true);
7578

76-
assert.equal(get(proxy, 'foo'), 1);
77-
assert.ok(!('foo' in content));
78-
assert.equal(get(proxy, 'hasBufferedChanges'), true);
79+
set(proxy, 'testing', '1234');
7980

80-
set(proxy, 'testing', '1234');
81+
assert.equal(get(proxy, 'testing'), '1234');
82+
assert.ok(!('testing' in content));
83+
assert.equal(get(proxy, 'hasBufferedChanges'), true);
8184

82-
assert.equal(get(proxy, 'testing'), '1234');
83-
assert.ok(!('testing' in content));
84-
assert.equal(get(proxy, 'hasBufferedChanges'), true);
85+
proxy.applyBufferedChanges(['foo']);
8586

86-
proxy.applyBufferedChanges(['foo']);
87+
assert.equal(get(proxy, 'foo'), 1);
88+
assert.ok('foo' in content);
89+
assert.ok(!('testing' in content));
90+
assert.equal(get(proxy, 'hasBufferedChanges'), true);
91+
assert.equal(get(content, 'foo'), 1);
92+
assert.equal(get(proxy, 'testing'), '1234');
8793

88-
assert.equal(get(proxy, 'foo'), 1);
89-
assert.ok('foo' in content);
90-
assert.ok(!('testing' in content));
91-
assert.equal(get(proxy, 'hasBufferedChanges'), true);
92-
assert.equal(get(content, 'foo'), 1);
93-
assert.equal(get(proxy, 'testing'), '1234');
94+
proxy.applyBufferedChanges(['testing']);
9495

95-
proxy.applyBufferedChanges(['testing']);
96+
assert.equal(get(proxy, 'testing'), '1234');
97+
assert.ok('testing' in content);
98+
assert.equal(get(proxy, 'hasBufferedChanges'), false);
99+
assert.equal(get(content, 'testing'), '1234');
96100

97-
assert.equal(get(proxy, 'testing'), '1234');
98-
assert.ok('testing' in content);
99-
assert.equal(get(proxy, 'hasBufferedChanges'), false);
100-
assert.equal(get(content, 'testing'), '1234');
101+
// Testing discardBufferdChanges with onlyTheseKeys
101102

102-
// Testing discardBufferdChanges with onlyTheseKeys
103+
proxy.setProperties({ bar: 2, example: 123 });
103104

104-
proxy.setProperties({ bar: 2, example: 123 });
105+
assert.equal(get(proxy, 'foo'), 1);
106+
assert.equal(get(proxy, 'bar'), 2);
107+
assert.equal(get(proxy, 'example'), 123);
105108

106-
assert.equal(get(proxy, 'foo'), 1);
107-
assert.equal(get(proxy, 'bar'), 2);
108-
assert.equal(get(proxy, 'example'), 123);
109+
assert.ok('foo' in content);
110+
assert.ok('testing' in content);
111+
assert.ok(!('bar' in content));
112+
assert.ok(!('example' in content));
109113

110-
assert.ok('foo' in content);
111-
assert.ok('testing' in content);
112-
assert.ok(!('bar' in content));
113-
assert.ok(!('example' in content));
114+
assert.equal(get(proxy, 'hasBufferedChanges'), true);
114115

115-
assert.equal(get(proxy, 'hasBufferedChanges'), true);
116+
proxy.discardBufferedChanges(['bar']);
116117

117-
proxy.discardBufferedChanges(['bar']);
118+
assert.equal(get(proxy, 'foo'), 1);
119+
assert.equal(get(proxy, 'testing'), '1234');
120+
assert.equal(get(proxy, 'bar'), undefined);
121+
assert.equal(get(proxy, 'example'), 123);
118122

119-
assert.equal(get(proxy, 'foo'), 1);
120-
assert.equal(get(proxy, 'testing'), '1234');
121-
assert.equal(get(proxy, 'bar'), undefined);
122-
assert.equal(get(proxy, 'example'), 123);
123+
assert.ok('foo' in content);
124+
assert.ok('testing' in content);
125+
assert.ok(!('bar' in content));
126+
assert.ok(!('example' in content));
127+
assert.equal(get(proxy, 'hasBufferedChanges'), true);
123128

124-
assert.ok('foo' in content);
125-
assert.ok('testing' in content);
126-
assert.ok(!('bar' in content));
127-
assert.ok(!('example' in content));
128-
assert.equal(get(proxy, 'hasBufferedChanges'), true);
129+
proxy.discardBufferedChanges(['example']);
129130

130-
proxy.discardBufferedChanges(['example']);
131+
assert.equal(get(proxy, 'foo'), 1);
132+
assert.equal(get(proxy, 'testing'), '1234');
133+
assert.equal(get(proxy, 'bar'), undefined);
134+
assert.equal(get(proxy, 'example'), undefined);
131135

132-
assert.equal(get(proxy, 'foo'), 1);
133-
assert.equal(get(proxy, 'testing'), '1234');
134-
assert.equal(get(proxy, 'bar'), undefined);
135-
assert.equal(get(proxy, 'example'), undefined);
136+
assert.ok('foo' in content);
137+
assert.ok('testing' in content);
138+
assert.ok(!('bar' in content));
139+
assert.ok(!('example' in content));
140+
assert.equal(get(proxy, 'hasBufferedChanges'), false);
136141

137-
assert.ok('foo' in content);
138-
assert.ok('testing' in content);
139-
assert.ok(!('bar' in content));
140-
assert.ok(!('example' in content));
141-
assert.equal(get(proxy, 'hasBufferedChanges'), false);
142+
assert.equal(get(proxy, 'baz'), 1);
143+
assert.equal(get(content, 'baz'), 1);
144+
});
142145

143-
assert.equal(get(proxy, 'baz'), 1);
144-
assert.equal(get(content, 'baz'), 1);
145-
});
146+
test('aliased methods work', (assert) => {
147+
const BufferedProxy = ObjectProxy.extend(Mixin);
148+
const proxy = BufferedProxy.create({
149+
content: { property: 1 }
150+
});
146151

147-
test('aliased methods work', (assert) => {
148-
const BufferedProxy = ObjectProxy.extend(Mixin);
149-
const proxy = BufferedProxy.create({
150-
content: { property: 1 }
151-
});
152+
set(proxy, 'property', 2);
153+
assert.ok(get(proxy, 'hasChanges'), 'Modified proxy has changes');
152154

153-
set(proxy, 'property', 2);
154-
assert.ok(get(proxy, 'hasChanges'), 'Modified proxy has changes');
155+
proxy.applyChanges();
156+
assert.equal(get(proxy, 'content.property'), 2, 'Applying changes sets the content\'s property');
157+
assert.ok(!(get(proxy, 'hasChanges')), 'Proxy has no changes after changes are applied');
155158

156-
proxy.applyChanges();
157-
assert.equal(get(proxy, 'content.property'), 2, 'Applying changes sets the content\'s property');
158-
assert.ok(!(get(proxy, 'hasChanges')), 'Proxy has no changes after changes are applied');
159+
set(proxy, 'baz', 3);
160+
proxy.discardChanges();
161+
assert.equal(get(proxy, 'property'), 2, 'Discarding changes resets the proxy\'s property');
162+
assert.ok(!(get(proxy, 'hasChanges')), 'Proxy has no changes after changes are discarded');
163+
});
159164

160-
set(proxy, 'baz', 3);
161-
proxy.discardChanges();
162-
assert.equal(get(proxy, 'property'), 2, 'Discarding changes resets the proxy\'s property');
163-
assert.ok(!(get(proxy, 'hasChanges')), 'Proxy has no changes after changes are discarded');
164-
});
165+
test('allows passing other variables at .create time', (assert) => {
166+
const BufferedProxy = ObjectProxy.extend(Mixin);
167+
const fakeContainer = EmberObject.create({});
165168

166-
test('allows passing other variables at .create time', (assert) => {
167-
const BufferedProxy = ObjectProxy.extend(Mixin);
168-
const fakeContainer = EmberObject.create({});
169+
var proxy = BufferedProxy.create({
170+
content: { property: 1 },
171+
container: fakeContainer,
172+
foo: 'foo',
173+
});
169174

170-
var proxy = BufferedProxy.create({
171-
content: { property: 1 },
172-
container: fakeContainer,
173-
foo: 'foo',
175+
assert.equal(proxy.get('container'), fakeContainer, 'Proxy didn\'t allow defining container property at create time');
176+
assert.equal(proxy.get('foo'), 'foo', 'Proxy didn\'t allow setting an arbitrary value at create time');
174177
});
175178

176-
assert.equal(proxy.get('container'), fakeContainer, 'Proxy didn\'t allow defining container property at create time');
177-
assert.equal(proxy.get('foo'), 'foo', 'Proxy didn\'t allow setting an arbitrary value at create time');
178-
});
179+
test('that .hasChanged() works', (assert) => {
180+
const BufferedProxy = ObjectProxy.extend(Mixin);
181+
const content = {};
179182

180-
test('that .hasChanged() works', (assert) => {
181-
const BufferedProxy = ObjectProxy.extend(Mixin);
182-
const content = {};
183+
const proxy = BufferedProxy.create({ content });
183184

184-
const proxy = BufferedProxy.create({ content });
185+
set(proxy, 'foo', 1);
185186

186-
set(proxy, 'foo', 1);
187+
assert.equal(proxy.hasChanged('foo'), true);
188+
assert.equal(proxy.hasChanged('bar'), false);
187189

188-
assert.equal(proxy.hasChanged('foo'), true);
189-
assert.equal(proxy.hasChanged('bar'), false);
190+
set(proxy, 'bar', 1);
190191

191-
set(proxy, 'bar', 1);
192+
assert.equal(proxy.hasChanged('foo'), true);
193+
assert.equal(proxy.hasChanged('bar'), true);
192194

193-
assert.equal(proxy.hasChanged('foo'), true);
194-
assert.equal(proxy.hasChanged('bar'), true);
195+
proxy.applyBufferedChanges(['bar']);
195196

196-
proxy.applyBufferedChanges(['bar']);
197+
set(proxy, 'foobar', false);
197198

198-
set(proxy, 'foobar', false);
199+
assert.equal(proxy.hasChanged('foo'), true);
200+
assert.equal(proxy.hasChanged('bar'), false);
201+
assert.equal(proxy.hasChanged('foobar'), true);
199202

200-
assert.equal(proxy.hasChanged('foo'), true);
201-
assert.equal(proxy.hasChanged('bar'), false);
202-
assert.equal(proxy.hasChanged('foobar'), true);
203+
proxy.applyBufferedChanges();
203204

204-
proxy.applyBufferedChanges();
205+
assert.equal(proxy.hasChanged('foo'), false);
206+
assert.equal(proxy.hasChanged('bar'), false);
207+
assert.equal(proxy.hasChanged('foobar'), false);
205208

206-
assert.equal(proxy.hasChanged('foo'), false);
207-
assert.equal(proxy.hasChanged('bar'), false);
208-
assert.equal(proxy.hasChanged('foobar'), false);
209-
210-
assert.equal(proxy.hasChanged(), false, 'Not passing a key returns false');
211-
assert.equal(proxy.hasChanged('baz'), false, 'If the key does not exist on the proxy then return false');
209+
assert.equal(proxy.hasChanged(), false, 'Not passing a key returns false');
210+
assert.equal(proxy.hasChanged('baz'), false, 'If the key does not exist on the proxy then return false');
211+
});
212212
});

tests/unit/proxy-test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import {
55
test
66
} from 'qunit';
77

8-
module('ember-buffered-proxy/mixin');
8+
module('ember-buffered-proxy/proxy', function() {
9+
test('exists', (assert) => {
10+
assert.ok(BufferedProxy);
11+
});
912

10-
test('exists', (assert) => {
11-
assert.ok(BufferedProxy);
12-
});
13-
14-
test('that appears correct', (assert) => {
15-
assert.ok(BufferedMixin.detect(BufferedProxy.create()));
13+
test('that appears correct', (assert) => {
14+
assert.ok(BufferedMixin.detect(BufferedProxy.create()));
15+
});
1616
});

0 commit comments

Comments
 (0)