Skip to content

Commit

Permalink
refactor: test attribute removed from menu-button template
Browse files Browse the repository at this point in the history
  • Loading branch information
roomman committed Nov 22, 2021
1 parent d4944e5 commit aaa7c54
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
1 change: 0 additions & 1 deletion addon/components/menu/button.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{{! template-lint-disable no-down-event-binding }}
<button
data-test-headlessui-menu-button
type='button'
aria-haspopup={{true}}
aria-controls={{if @isOpen @itemsGuid}}
Expand Down
26 changes: 19 additions & 7 deletions tests/integration/components/menu-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function getMenu() {
}

function getMenuButton() {
return find('button,[role="button"],[id^="headlessui-menu-button-"]');
return find('button,[role="button"],[data-test-menu-button]');
}

function getMenuItems() {
Expand Down Expand Up @@ -771,7 +771,7 @@ module('Integration | Component | <Menu>', (hooks) => {
assertMenuLinkedWithMenuItem(items[2]);
});

test('it should have no active menu item upon Space key press, when there are no non-disabled menu items', async function () {
test('it should have no active menu item upon Space key press, when there are no non-disabled menu items', async function (assert) {
await render(hbs`
<Menu as |menu|>
<menu.Button data-test-menu-button>Trigger</menu.Button>
Expand Down Expand Up @@ -802,14 +802,14 @@ module('Integration | Component | <Menu>', (hooks) => {
await triggerKeyEvent('[data-test-menu-button]', 'keydown', Keys.Space);

// Verify is has menu items
const items = getMenuItems();

assert.strictEqual(
items.length,
3,
'There are three visible menu items'
);

assertMenuLinkedWithMenuItem(items[0]);

assertNoActiveMenuItem();
});

Expand Down Expand Up @@ -1041,7 +1041,11 @@ module('Integration | Component | <Menu>', (hooks) => {
const items = getMenuItems();

// Verify we have menu items
assert.equal(items.length, 3, 'There are three visible menu items');
assert.strictEqual(
items.length,
3,
'There are three visible menu items'
);
assertMenuLinkedWithMenuItem(items[0]);

// Try to Shit+Tab
Expand Down Expand Up @@ -1101,7 +1105,11 @@ module('Integration | Component | <Menu>', (hooks) => {
const items = getMenuItems();

// Verify we have menu items
assert.equal(items.length, 3, 'There are three visible menu items');
assert.strictEqual(
items.length,
3,
'There are three visible menu items'
);

// Verify that the first menu item is active
assertMenuLinkedWithMenuItem(items[0]);
Expand Down Expand Up @@ -1213,7 +1221,11 @@ module('Integration | Component | <Menu>', (hooks) => {
const items = getMenuItems();

// Verify we have menu items
assert.equal(items.length, 3, 'There are three visible menu items');
assert.strictEqual(
items.length,
3,
'There are three visible menu items'
);
assertMenuLinkedWithMenuItem(items[0]);

// We should be able to go down once
Expand Down

0 comments on commit aaa7c54

Please sign in to comment.