From d0c04d1a78e098bc49674dcdb845064116efbd6e Mon Sep 17 00:00:00 2001 From: Dan Freeman Date: Tue, 15 Jan 2019 17:29:53 -0500 Subject: [PATCH] Add tests for positional params with custom component managers (cherry picked from commit 5639352ba9a3b0fbc5d258eb8cb3625065ee9f1e) --- .../custom-component-manager-test.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/packages/@ember/-internals/glimmer/tests/integration/custom-component-manager-test.js b/packages/@ember/-internals/glimmer/tests/integration/custom-component-manager-test.js index 5608f28aec9..f0bcb33e2ab 100644 --- a/packages/@ember/-internals/glimmer/tests/integration/custom-component-manager-test.js +++ b/packages/@ember/-internals/glimmer/tests/integration/custom-component-manager-test.js @@ -305,6 +305,58 @@ if (GLIMMER_CUSTOM_COMPONENT_MANAGER) { this.assertHTML(`

Chad Hietala

`); } + ['@test it can set positional params on the component instance']() { + let ComponentClass = setComponentManager( + createBasicManager, + EmberObject.extend({ + salutation: computed('args.positional', function() { + return this.args.positional[0] + ' ' + this.args.positional[1]; + }), + }) + ); + + this.registerComponent('foo-bar', { + template: `

{{salutation}}

`, + ComponentClass, + }); + + this.render('{{foo-bar "Yehuda" "Katz"}}'); + + this.assertHTML(`

Yehuda Katz

`); + } + + ['@test positional params are updated if they change']() { + let ComponentClass = setComponentManager( + createBasicManager, + EmberObject.extend({ + salutation: computed('args.positional', function() { + return this.args.positional[0] + ' ' + this.args.positional[1]; + }), + }) + ); + + this.registerComponent('foo-bar', { + template: `

{{salutation}}

`, + ComponentClass, + }); + + this.render('{{foo-bar firstName lastName}}', { + firstName: 'Yehuda', + lastName: 'Katz', + }); + + this.assertHTML(`

Yehuda Katz

`); + + runTask(() => + setProperties(this.context, { + firstName: 'Chad', + lastName: 'Hietala', + }) + ); + + this.assertHTML(`

Chad Hietala

`); + } + ['@test it can opt-in to running destructor'](assert) { let ComponentClass = setComponentManager( () => {