Skip to content

Commit

Permalink
Merge pull request #14279 from emberjs/ensure-set-in-willdestroyeleme…
Browse files Browse the repository at this point in the history
…nt-is-ok

Add passing regression test to confirm setting in willDestroyElement works.
  • Loading branch information
rwjblue authored Sep 13, 2016
2 parents f66b62e + e706e4e commit aeeddf7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,31 @@ moduleFor('Components test: curly components', class extends RenderingTest {
this.assert.ok(true, 'no errors during teardown');
}

['@test setting a property in willDestroyElement does not assert (GH#14273)'](assert) {
assert.expect(2);

this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
init() {
this._super(...arguments);
this.showFoo = true;
},

willDestroyElement() {
this.set('showFoo', false);
assert.ok(true, 'willDestroyElement was fired');
this._super(...arguments);
}
}),

template: `{{#if showFoo}}things{{/if}}`
});

this.render(`{{foo-bar}}`);

this.assertText('things');
}

['@test using didInitAttrs as an event is deprecated'](assert) {
this.registerComponent('foo-bar', {
ComponentClass: Component.extend({
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-glimmer/tests/utils/abstract-test-case.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ export class TestCase {
}

assertText(text) {
this.assert.strictEqual(this.textValue(), text, '#qunit-fixture content');
this.assert.strictEqual(this.textValue(), text, `#qunit-fixture content should be: \`${text}\``);
}

assertInnerHTML(html) {
equalInnerHTML(this.element, html);
}

assertHTML(html) {
equalTokens(this.element, html, '#qunit-fixture content');
equalTokens(this.element, html, `#qunit-fixture content should be: \`${html}\``);
}

assertElement(node, { ElementType = HTMLElement, tagName, attrs = null, content = null }) {
Expand Down

0 comments on commit aeeddf7

Please sign in to comment.