Skip to content

Commit

Permalink
use hasAria/doesNotHaveAria
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescdavis committed Mar 2, 2022
1 parent 1d131bc commit f60a821
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 77 deletions.
110 changes: 55 additions & 55 deletions tests/integration/components/power-select/a11y-test.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ module('Integration | Component | Ember Power Select (Custom search function)',
typeInSearch('teen');

await settled();
assert.dom('.ember-power-select-option').hasAttribute('aria-current', 'true', 'The first result is highlighted');
assert.dom('.ember-power-select-option').hasAria('current', 'true', 'The first result is highlighted');
});
test('On an empty select, when a syncronous search result complete, the first element is highlighted like with regular filtering', async function(assert) {
assert.expect(1);
Expand All @@ -289,7 +289,7 @@ module('Integration | Component | Ember Power Select (Custom search function)',
typeInSearch('teen');

await settled();
assert.dom('.ember-power-select-option').hasAttribute('aria-current', 'true', 'The first result is highlighted');
assert.dom('.ember-power-select-option').hasAria('current', 'true', 'The first result is highlighted');
});

test('On an select with a selected value, if after a search this value is not among the options the first element is highlighted', async function(assert) {
Expand All @@ -312,11 +312,11 @@ module('Integration | Component | Ember Power Select (Custom search function)',
`);

await clickTrigger();
assert.dom('.ember-power-select-option:nth-child(3)').hasAttribute('aria-current', 'true', 'The 3rd result is highlighted');
assert.dom('.ember-power-select-option:nth-child(3)').hasAria('current', 'true', 'The 3rd result is highlighted');
typeInSearch('teen');

await settled();
assert.dom('.ember-power-select-option').hasAttribute('aria-current', 'true', 'The first result is highlighted');
assert.dom('.ember-power-select-option').hasAria('current', 'true', 'The first result is highlighted');
});

test('Closing a component with a custom search cleans the search box and the results list', async function(assert) {
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/components/power-select/disabled-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module('Integration | Component | Ember Power Select (Disabled)', function(hooks
</PowerSelect>
`);

assert.dom('.ember-power-select-trigger').hasAttribute('aria-disabled', 'true');
assert.dom('.ember-power-select-trigger').hasAria('disabled', 'true');
await clickTrigger();
assert.dom('.ember-power-select-dropdown').doesNotExist('The select is still closed');
await triggerKeyEvent('.ember-power-select-trigger', 'keydown', 13);
Expand Down Expand Up @@ -50,7 +50,7 @@ module('Integration | Component | Ember Power Select (Disabled)', function(hooks

await clickTrigger();
await triggerEvent('.ember-power-select-option[aria-disabled="true"]', 'mouseover');
assert.dom('.ember-power-select-option[aria-disabled="true"]').hasAttribute('aria-current', 'false', 'The hovered option was not highlighted because it\'s disabled');
assert.dom('.ember-power-select-option[aria-disabled="true"]').hasAria('current', 'false', 'The hovered option was not highlighted because it\'s disabled');
});

test('Disabled options are skipped when highlighting items with the keyboard', async function(assert) {
Expand Down Expand Up @@ -110,9 +110,9 @@ module('Integration | Component | Ember Power Select (Disabled)', function(hooks
</PowerSelectMultiple>
`);

assert.dom('.ember-power-select-trigger').hasAttribute('aria-disabled', 'true', 'The trigger has `aria-disabled=true`');
assert.dom('.ember-power-select-trigger').hasAria('disabled', 'true', 'The trigger has `aria-disabled=true`');
this.set('shouldBeDisabled', false);
assert.dom('.ember-power-select-trigger').hasAttribute('aria-expanded', 'false')
assert.dom('.ember-power-select-trigger').hasAria('expanded', 'false')
assert.dom('.ember-power-select-trigger-multiple-input').doesNotHaveAttribute('disabled');
});

Expand Down Expand Up @@ -283,7 +283,7 @@ module('Integration | Component | Ember Power Select (Disabled)', function(hooks
await clickTrigger();
await click(document.querySelectorAll('.ember-power-select-option')[1]);
assert.dom('.ember-power-select-trigger').hasText('two', 'The option is selected');
assert.dom('.ember-power-select-trigger').hasAttribute('aria-disabled', 'true');
assert.dom('.ember-power-select-trigger').hasAria('disabled', 'true');
});

test('Disabled options cannot be selected', async function(assert) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ module('Integration | Component | Ember Power Select (General behavior)', functi
await clickTrigger();
assert.dom('.ember-power-select-dropdown').exists('Dropdown is rendered');
assert.dom('.ember-power-select-option[aria-current="true"]').exists({ count: 1 }, 'One element is highlighted');
assert.dom('.ember-power-select-option').hasAttribute('aria-current', 'true', 'The first one to be precise');
assert.dom('.ember-power-select-option').hasAria('current', 'true', 'The first one to be precise');
});

test('When `selected` option is provided, it appears in the trigger yielded with the same block as the options', async function(assert) {
Expand Down Expand Up @@ -549,7 +549,7 @@ module('Integration | Component | Ember Power Select (General behavior)', functi
`);

await clickTrigger();
assert.dom('.ember-power-select-option:nth-child(3)').hasAttribute('aria-selected', 'true', 'The third option is marked as selected');
assert.dom('.ember-power-select-option:nth-child(3)').hasAria('selected', 'true', 'The third option is marked as selected');
});

test('The default search strategy matches disregarding diacritics differences and capitalization', async function(assert) {
Expand Down Expand Up @@ -610,7 +610,7 @@ module('Integration | Component | Ember Power Select (General behavior)', functi
await clickTrigger();
assert.dom('.ember-power-select-dropdown').exists('Dropdown is rendered');
assert.dom('.ember-power-select-option[aria-current="true"]').exists({ count: 1 }, 'One element is highlighted');
assert.dom('.ember-power-select-option:nth-child(1)').hasAttribute('aria-current', 'true', 'The first one to be precise');
assert.dom('.ember-power-select-option:nth-child(1)').hasAria('current', 'true', 'The first one to be precise');
});

test('When a option is provided that options is rendered in the trigger using the same block as the options', async function(assert) {
Expand Down Expand Up @@ -656,7 +656,7 @@ module('Integration | Component | Ember Power Select (General behavior)', functi

await clickTrigger();
let selectedOption = findContains('.ember-power-select-option', 'ES: Spain');
assert.dom(selectedOption).hasAttribute('aria-selected', 'true', 'The second option is marked as selected');
assert.dom(selectedOption).hasAria('selected', 'true', 'The second option is marked as selected');
});

test('The default search strategy matches disregarding diacritics differences and capitalization', async function(assert) {
Expand Down Expand Up @@ -1106,7 +1106,7 @@ module('Integration | Component | Ember Power Select (General behavior)', functi
await click('.ember-power-select-option:nth-child(2)');
await clickTrigger();
await typeInSearch('i');
assert.dom('.ember-power-select-option:nth-child(1)').hasAttribute('aria-selected', 'true', 'The item in the list is marked as selected');
assert.dom('.ember-power-select-option:nth-child(1)').hasAria('selected', 'true', 'The item in the list is marked as selected');
await click('.ember-power-select-option:nth-child(1)');
assert.equal(onChangeInvocationsCount, 1);
});
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/components/power-select/mouse-control-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ module('Integration | Component | Ember Power Select (Mouse control)', function(
`);

await clickTrigger();
assert.dom('.ember-power-select-option').hasAttribute('aria-current', 'true', 'The first element is highlighted');
assert.dom('.ember-power-select-option').hasAria('current', 'true', 'The first element is highlighted');
await triggerEvent('.ember-power-select-option:nth-child(4)', 'mouseover');
assert.dom('.ember-power-select-option:nth-child(4)').hasAttribute('aria-current', 'true', 'The 4th element is highlighted');
assert.dom('.ember-power-select-option:nth-child(4)').hasAria('current', 'true', 'The 4th element is highlighted');
assert.dom('.ember-power-select-option:nth-child(4)').hasText('four');
});

Expand All @@ -37,11 +37,11 @@ module('Integration | Component | Ember Power Select (Mouse control)', function(
`);

await clickTrigger();
assert.dom('.ember-power-select-option').hasAttribute('aria-current', 'true', 'The first element is highlighted');
assert.dom('.ember-power-select-option').hasAria('current', 'true', 'The first element is highlighted');
await triggerEvent('.ember-power-select-option:nth-child(4)', 'mouseover');

assert.dom('.ember-power-select-option:nth-child(4)').hasAttribute('aria-current', 'false', 'The 4th element is not highlighted');
assert.dom('.ember-power-select-option:nth-child(1)').hasAttribute('aria-current', 'true', 'The 1st element is still highlighted');
assert.dom('.ember-power-select-option:nth-child(4)').hasAria('current', 'false', 'The 4th element is not highlighted');
assert.dom('.ember-power-select-option:nth-child(1)').hasAria('current', 'true', 'The 1st element is still highlighted');
});

test('Clicking an item selects it, closes the dropdown and focuses the trigger', async function(assert) {
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/components/power-select/multiple-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ module('Integration | Component | Ember Power Select (Multiple)', function(hooks
`);

await clickTrigger();
assert.dom('.ember-power-select-option:nth-child(2)').hasAttribute('aria-selected', 'true', 'The second option is styled as selected');
assert.dom('.ember-power-select-option:nth-child(4)').hasAttribute('aria-selected', 'true', 'The 4th option is styled as selected');
assert.dom('.ember-power-select-option:nth-child(2)').hasAria('selected', 'true', 'The second option is styled as selected');
assert.dom('.ember-power-select-option:nth-child(4)').hasAria('selected', 'true', 'The 4th option is styled as selected');
});

test('When the popup opens, the first items is highlighed, even if there is only one selection', async function(assert) {
Expand Down Expand Up @@ -830,7 +830,7 @@ module('Integration | Component | Ember Power Select (Multiple)', function(hooks
await typeInSearch('M');
await click('.ember-power-select-option:nth-child(2)');
await typeInSearch('Mi');
assert.dom('.ember-power-select-option').hasAttribute('aria-selected', 'true', 'The item in the list is marked as selected');
assert.dom('.ember-power-select-option').hasAria('selected', 'true', 'The item in the list is marked as selected');
await click('.ember-power-select-option'); // select the same user again should remove it
assert.dom('.ember-power-select-multiple-option').exists({ count: 0 });
});
Expand Down

0 comments on commit f60a821

Please sign in to comment.