Skip to content

Commit 91b04e2

Browse files
committed
Add test to ensure disabled item does not get committed
1 parent 6306e95 commit 91b04e2

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

test/test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ describe('combobox-nav', function() {
4646
<li><del>BB-8</del></li>
4747
<li id="hubot" role="option">Hubot</li>
4848
<li id="r2-d2" role="option">R2-D2</li>
49+
<li id="wall-e" role="option" aria-disabled="true">Wall-E</li>
4950
</ul>
5051
`
5152
comboboxNav.install(document.querySelector('input'), document.querySelector('ul'))
@@ -79,18 +80,23 @@ describe('combobox-nav', function() {
7980
assert.equal(options[3].getAttribute('aria-selected'), 'true')
8081
assert.equal(input.getAttribute('aria-activedescendant'), 'r2-d2')
8182

83+
press(input, 'n', true)
84+
assert.equal(options[4].getAttribute('aria-selected'), 'true')
85+
assert.equal(input.getAttribute('aria-activedescendant'), 'wall-e')
86+
press(input, 'Enter')
87+
8288
press(input, 'p', true)
83-
assert.equal(options[2].getAttribute('aria-selected'), 'true')
84-
assert.equal(input.getAttribute('aria-activedescendant'), 'hubot')
89+
assert.equal(options[3].getAttribute('aria-selected'), 'true')
90+
assert.equal(input.getAttribute('aria-activedescendant'), 'r2-d2')
8591

8692
press(input, 'ArrowUp')
87-
assert.equal(options[0].getAttribute('aria-selected'), 'true')
88-
assert.equal(input.getAttribute('aria-activedescendant'), 'baymax')
93+
assert.equal(options[2].getAttribute('aria-selected'), 'true')
94+
assert.equal(input.getAttribute('aria-activedescendant'), 'hubot')
8995

9096
press(input, 'Enter')
9197
assert.equal(expectedTargets.length, 2)
9298
assert.equal(expectedTargets[0], 'hubot')
93-
assert.equal(expectedTargets[1], 'baymax')
99+
assert.equal(expectedTargets[1], 'hubot')
94100
})
95101

96102
it('fires commit events on click', function() {

0 commit comments

Comments
 (0)