From 4ff4da9c24d5a33f49781f93b437a51a2355080c Mon Sep 17 00:00:00 2001 From: Christopher Garrett Date: Wed, 17 Jan 2018 20:47:43 -0800 Subject: [PATCH] [TESTS es-classes] Adds a failing test for didReceiveAttrs Adds a failing test for didReceiveAttrs in native classes. Class fields will likely be the prefered way to initialize default values on class instances, but because didReceiveAttrs is called in the base class constructor it is initially called before class fields have had an opportunity to be setup. --- .../components/curly-components-test.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/packages/ember-glimmer/tests/integration/components/curly-components-test.js b/packages/ember-glimmer/tests/integration/components/curly-components-test.js index 999d21e6d0e..7a04e8b6215 100644 --- a/packages/ember-glimmer/tests/integration/components/curly-components-test.js +++ b/packages/ember-glimmer/tests/integration/components/curly-components-test.js @@ -3119,6 +3119,24 @@ moduleFor('Components test: curly components', class extends RenderingTest { this.assertText('3'); } + + ['@test has attrs by didReceiveAttrs with native classes'](assert) { + class FooBarComponent extends Component { + constructor() { + super(); + // analagous to class field defaults + this.foo = 'bar'; + } + + didReceiveAttrs() { + assert.equal(this.foo, 'bar', 'received default attrs correctly'); + } + } + + this.registerComponent('foo-bar', { ComponentClass: FooBarComponent }); + + this.render('{{foo-bar}}'); + } }); if (jQueryDisabled) { @@ -3199,4 +3217,4 @@ if (jQueryDisabled) { } }); -} \ No newline at end of file +}