Skip to content

Commit 9b64e4c

Browse files
committed
add tests
1 parent 493429c commit 9b64e4c

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,27 @@ describe('tab-container', function() {
9393
// The event listener should have been called.
9494
assert.equal(counter, 1)
9595
})
96+
97+
it('the aria-selected attribute is set to "false" for all tabs that don\'t have a aria-selected attribute', function() {
98+
for (const tab of document.querySelectorAll('[role="tab"]:not([aria-selected="true"])')) {
99+
assert.equal(tab.getAttribute('aria-selected'), 'false')
100+
}
101+
})
102+
103+
it('the tabindex attribute is set to "0" for the selected tab', function() {
104+
assert.equal(document.querySelector('[role="tab"][aria-selected="true"]').getAttribute('tabindex'), '0')
105+
})
106+
107+
it('the tabindex attribute is set to "-1" for the non-selected tabs', function() {
108+
for (const tab of document.querySelectorAll('[role="tab"]:not([aria-selected="true"])')) {
109+
assert.equal(tab.getAttribute('tabindex'), '-1')
110+
}
111+
})
112+
it('selected tab has tabindex="0" after selection', function() {
113+
const tabs = document.querySelectorAll('[role="tab"]')
114+
115+
tabs[1].click()
116+
assert.equal(tabs[1].getAttribute('tabindex'), '0')
117+
})
96118
})
97119
})

0 commit comments

Comments
 (0)