Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX master] Add test for positional params passed explicitly. #14533

Merged
merged 1 commit into from
Oct 27, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Component } from '../../utils/helpers';
import { applyMixins, strip } from '../../utils/abstract-test-case';
import { moduleFor, RenderingTest } from '../../utils/test-case';
import { isEmpty } from 'ember-metal';
import { A as emberA } from 'ember-runtime/system/native_array';

moduleFor('Components test: closure components', class extends RenderingTest {
['@test renders with component helper']() {
Expand Down Expand Up @@ -1000,6 +1001,84 @@ moduleFor('Components test: closure components', class extends RenderingTest {
assert.equal(initCount, 3, 'the component was constructed exactly 3 times (rerender)');
assert.equal(this.$().text(), 'my-comp: open');
}

['@test GH#14508 rest positional params are received when passed as named parameter']() {
this.registerComponent('my-link', {
ComponentClass: Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});

this.render('{{component (component "my-link") params=allParams}}', {
allParams: emberA(['a', 'b'])
});

this.assertText('ab');

this.runTask(() => this.rerender());

this.assertText('ab');

this.runTask(() => this.context.get('allParams').pushObject('c'));

this.assertText('abc');

this.runTask(() => this.context.get('allParams').popObject());

this.assertText('ab');

this.runTask(() => this.context.get('allParams').clear());

this.assertText('');

this.runTask(() => this.context.set('allParams', emberA(['1', '2'])));

this.assertText('12');

this.runTask(() => this.context.set('allParams', emberA(['a', 'b'])));

this.assertText('ab');
}

['@test GH#14508 rest positional params are received when passed as named parameter with dot notation']() {
this.registerComponent('my-link', {
ComponentClass: Component.extend().reopenClass({
positionalParams: 'params'
}),
template: '{{#each params as |p|}}{{p}}{{/each}}'
});

this.render('{{#with (hash link=(component "my-link")) as |c|}}{{c.link params=allParams}}{{/with}}', {
allParams: emberA(['a', 'b'])
});

this.assertText('ab');

this.runTask(() => this.rerender());

this.assertText('ab');

this.runTask(() => this.context.get('allParams').pushObject('c'));

this.assertText('abc');

this.runTask(() => this.context.get('allParams').popObject());

this.assertText('ab');

this.runTask(() => this.context.get('allParams').clear());

this.assertText('');

this.runTask(() => this.context.set('allParams', emberA(['1', '2'])));

this.assertText('12');

this.runTask(() => this.context.set('allParams', emberA(['a', 'b'])));

this.assertText('ab');
}
});

class ClosureComponentMutableParamsTest extends RenderingTest {
Expand Down