Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorGeoSot <geo.sotis@gmail.com>2022-09-23 23:18:57 +0300
committerGitHub <noreply@github.com>2022-09-23 23:18:57 +0300
commit24f6e2764a557afdf0cabfc28067fe1078e0a0ee (patch)
tree90c67ca07a097ed52bde91fbbea19b31b86f7546 /js
parent8da10bb1be424dd42cf5944f124fc8f3245a0cfe (diff)
Tests: add testcase to Tabs, keyboard handler (#37189)
Diffstat (limited to 'js')
-rw-r--r--js/tests/unit/tab.spec.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/js/tests/unit/tab.spec.js b/js/tests/unit/tab.spec.js
index b00014eed0..5ffc733832 100644
--- a/js/tests/unit/tab.spec.js
+++ b/js/tests/unit/tab.spec.js
@@ -513,15 +513,19 @@ describe('Tab', () => {
'<div class="nav">',
' <span id="tab1" class="nav-link" data-bs-toggle="tab"></span>',
' <span id="tab2" class="nav-link" data-bs-toggle="tab"></span>',
+ ' <span id="tab3" class="nav-link" data-bs-toggle="tab"></span>',
'</div>'
].join('')
- const tabEl = fixtureEl.querySelector('#tab1')
+ const tabEl1 = fixtureEl.querySelector('#tab1')
const tabEl2 = fixtureEl.querySelector('#tab2')
- const tab = new Tab(tabEl)
+ const tabEl3 = fixtureEl.querySelector('#tab3')
+ const tab1 = new Tab(tabEl1)
const tab2 = new Tab(tabEl2)
- const spyShow1 = spyOn(tab, 'show').and.callThrough()
+ const tab3 = new Tab(tabEl3)
+ const spyShow1 = spyOn(tab1, 'show').and.callThrough()
const spyShow2 = spyOn(tab2, 'show').and.callThrough()
+ const spyShow3 = spyOn(tab3, 'show').and.callThrough()
const spyStop = spyOn(Event.prototype, 'stopPropagation').and.callThrough()
const spyPrevent = spyOn(Event.prototype, 'preventDefault').and.callThrough()
@@ -529,17 +533,20 @@ describe('Tab', () => {
let keydown = createEvent('keydown')
keydown.key = 'ArrowRight'
- tabEl.dispatchEvent(keydown)
+ tabEl1.dispatchEvent(keydown)
expect(spyShow2).toHaveBeenCalled()
keydown = createEvent('keydown')
keydown.key = 'ArrowDown'
tabEl2.dispatchEvent(keydown)
+ expect(spyShow3).toHaveBeenCalled()
+
+ tabEl3.dispatchEvent(keydown)
expect(spyShow1).toHaveBeenCalled()
- expect(spyStop).toHaveBeenCalledTimes(2)
- expect(spyPrevent).toHaveBeenCalledTimes(2)
+ expect(spyStop).toHaveBeenCalledTimes(3)
+ expect(spyPrevent).toHaveBeenCalledTimes(3)
})
it('if keydown event is left arrow, handle it', () => {