Skip to content

Commit

Permalink
feat(Dropdown): Adds isOpen to dropdown template hash. Thanks to @the…
Browse files Browse the repository at this point in the history
  • Loading branch information
theroncross authored and simonihmig committed Mar 16, 2017
1 parent 682f75a commit 58abd4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions addon/templates/components/common/bs-dropdown.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
button=(component "bs-dropdown/button" dropdown=this onClick=(action "toggleDropdown"))
toggle=(component "bs-dropdown/toggle" dropdown=this inNav=inNav onClick=(action "toggleDropdown"))
menu=(component "bs-dropdown/menu")
isOpen=isOpen
)
}}
10 changes: 10 additions & 0 deletions tests/integration/components/bs-dropdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ test('clicking dropdown menu when closeOnMenuClick is false will not close it',
assert.equal(this.$(':first-child').hasClass(openClass()), true, 'Dropdown is open');
});

test('child components can access isOpen property', function(assert) {
this.render(hbs`{{#bs-dropdown as |dd|}}{{#dd.toggle}}<span id="toggleText">{{if dd.isOpen "open" "closed"}}</span>{{/dd.toggle}}{{/bs-dropdown}}`);

assert.equal(this.$('#toggleText').text(), 'closed', 'Dropdown is closed');
this.$('a.dropdown-toggle').click();
assert.equal(this.$('#toggleText').text(), 'open', 'Dropdown is open');
this.$('a.dropdown-toggle').click();
assert.equal(this.$('#toggleText').text(), 'closed', 'Dropdown is closed');
});

test('opening dropdown calls onShow action', function(assert) {
let action = this.spy();
this.on('show', action);
Expand Down

0 comments on commit 58abd4b

Please sign in to comment.