Skip to content

Commit

Permalink
Add test for issue #14469 to test closure action targets
Browse files Browse the repository at this point in the history
  • Loading branch information
zackthehuman committed Oct 16, 2016
1 parent cbe8b2f commit 45ec17b
Showing 1 changed file with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,53 @@ moduleFor('Helpers test: closure {{action}}', class extends RenderingTest {
this.assert.ok(actionCalled, 'action called on otherComponent');
}

['@test closure actions support a target [GH#14469]']() {
let innerComponent;
let actionCalled = false;
let actualName;
let expectedName = 'the foobar';

let InnerComponent = Component.extend({
init() {
this._super(...arguments);
innerComponent = this;
},
fireAction() {
this.attrs.submit();
}
});

let OuterComponent = Component.extend({
name: 'outer',
foobar: {
name: 'the foobar',
myName() {
actionCalled = true;
actualName = this.name;
}
}
});

this.registerComponent('inner-component', {
ComponentClass: InnerComponent,
template: 'inner'
});

this.registerComponent('outer-component', {
ComponentClass: OuterComponent,
template: `{{inner-component submit=(action foobar.myName target=foobar)}}`
});

this.render('{{outer-component}}');

this.runTask(() => {
innerComponent.fireAction();
});

this.assert.ok(actionCalled, 'action called on OuterComponent\'s foobar object');
this.assert.equal(actualName, expectedName, 'the foobar is the context');
}

['@test value can be used with action over actions']() {
let newValue = 'yelping yehuda';

Expand Down

0 comments on commit 45ec17b

Please sign in to comment.