Skip to content

Commit

Permalink
Merge pull request #75 from GavinJoyce/menu-control-actions
Browse files Browse the repository at this point in the history
feat(menu): yield actions to open/close menu
  • Loading branch information
alexlafroscia authored Aug 30, 2021
2 parents 812950c + 51879b1 commit 3edb816
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions addon/components/menu.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{yield
(hash
isOpen=this.isOpen
open=this.open
close=this.close
Button=(component
'menu/button'
buttonGuid=this.buttonGuid
Expand Down
23 changes: 23 additions & 0 deletions tests/integration/components/menu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,29 @@ module('Integration | Component | <Menu>', (hooks) => {
assertMenuItemsAreCollaped('[data-test-menu-items]');
});

test('controlling open/close programmatically', async (assert) => {
await render(hbs`
<Menu as |menu|>
<button data-test-open {{on 'click' menu.open}}>Open</button>
<button data-test-close {{on 'click' menu.close}}>Close</button>
<menu.Items data-test-menu-items as |items|>
<items.Item>Item A</items.Item>
<items.Item>Item B</items.Item>
<items.Item>Item C</items.Item>
</menu.Items>
</Menu>
`);

await click('[data-test-open]');

assert.dom('[data-test-menu-items]').exists();

await click('[data-test-close]');

assert.dom('[data-test-menu-items]').doesNotExist();
});

module('Rendering', () => {
module('Menu', () => {
test('Menu yields an object', async (assert) => {
Expand Down

0 comments on commit 3edb816

Please sign in to comment.