Skip to content

Commit

Permalink
Adds deprecation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
locks committed Jan 7, 2017
1 parent 3752909 commit bdf7a07
Showing 1 changed file with 36 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2897,18 +2897,27 @@ moduleFor('Components test: curly components', class extends RenderingTest {
assert.strictEqual(barCopyDidChangeCount, 1, 'expected observer firing for: barCopy');
}

['@test can access didInitAttrs arguments [DEPRECATED]'](assert) {
expectDeprecation(/didInitAttrs called/);

['@test overriding didReceiveAttrs does not trigger deprecation'](assert) {
this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
init() {
this._super(...arguments);
},
didReceiveAttrs() {
assert.equal(1, this.get('foo'), 'expected attrs to have correct value')
}
}),

didInitAttrs({ attrs }) {
assert.ok(this.didInit, 'expected init to have run before didInitAttrs');
this.set('fooCopy', attrs.foo.value + 1);
template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}'
});

this.render(`{{foo-bar foo=foo bar=bar}}`, { foo: 1, bar: 3 });
}

['@test can access didReceiveAttrs arguments [DEPRECATED]'](assert) {
expectDeprecation(/didReceiveAttrs.*stop taking arguments/);

this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
didReceiveAttrs({ attrs }) {
assert.equal(1, attrs.foo.value, 'expected attrs to have correct value')
}
}),

Expand All @@ -2918,28 +2927,30 @@ moduleFor('Components test: curly components', class extends RenderingTest {
this.render(`{{foo-bar foo=foo bar=bar}}`, { foo: 1, bar: 3 });
}

['@test can access did{Receive,Update}Attrs arguments [DEPRECATED]'](assert) {
// expectDeprecation(/didInitAttrs called/);
['@test can access didUpdateAttrs arguments [DEPRECATED]'](assert) {
expectDeprecation(/didUpdateAttrs.*stop taking arguments/);

this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
init() {
this._super(...arguments);
this.didInit = true;
},
didUpdateAttrs({ newAttrs }) {
assert.equal(5, newAttrs.foo.value, "expected newAttrs to have new value");
}
}),

didReceiveAttrs({ attrs }) {
assert.ok(this.didInit, 'expected init to have run before didInitAttrs');
this.set('fooCopy', attrs.foo.value + 1);
},
template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}'
});

didReceiveAttrs({ newAttrs }) {
assert.ok(this.didInit, 'expected init to have run before didReceiveAttrs');
this.set('barCopy', newAttrs.bar.value + 1);
},
this.render(`{{foo-bar foo=foo bar=bar}}`, { foo: 1, bar: 3 });

fooCopyDidChange: observer('fooCopy', () => { fooCopyDidChangeCount++; }),
barCopyDidChange: observer('barCopy', () => { barCopyDidChangeCount++; })
this.runTask(() => set(this.context, 'foo', 5));
}

['@test overriding didUpdateAttrs does not trigger deprecation'](assert) {
this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
didUpdateAttrs() {
assert.equal(5, this.get('foo'), "expected newAttrs to have new value");
}
}),

template: '{{foo}}-{{fooCopy}}-{{bar}}-{{barCopy}}'
Expand Down

0 comments on commit bdf7a07

Please sign in to comment.