Skip to content

Commit f17c37d

Browse files
committed
Add test for scrolling
1 parent 2e992fe commit f17c37d

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,5 +147,26 @@ describe('combobox-nav', function() {
147147
assert.equal(options[0].getAttribute('aria-selected'), 'false')
148148
assert.equal(input.hasAttribute('aria-activedescendant'), false)
149149
})
150+
151+
it('scrolls when the selected item is not in view', function() {
152+
const input = document.querySelector('input')
153+
const list = document.querySelector('ul')
154+
list.style.overflow = 'auto'
155+
list.style.height = '18px'
156+
list.style.position = 'relative'
157+
const options = document.querySelectorAll('li')
158+
assert.equal(list.scrollTop, 0)
159+
160+
press(input, 'ArrowDown')
161+
assert.equal(options[0].getAttribute('aria-selected'), 'true')
162+
assert.equal(input.getAttribute('aria-activedescendant'), 'baymax')
163+
assert.equal(list.scrollTop, 0)
164+
165+
press(input, 'ArrowDown')
166+
167+
assert.equal(options[2].getAttribute('aria-selected'), 'true')
168+
assert.equal(input.getAttribute('aria-activedescendant'), 'hubot')
169+
assert.equal(list.scrollTop, 36)
170+
})
150171
})
151172
})

0 commit comments

Comments
 (0)