Skip to content

Commit

Permalink
fix(jest): NcAppSidebarTabs
Browse files Browse the repository at this point in the history
Signed-off-by: Christopher Ng <chrng8@gmail.com>
  • Loading branch information
Pytal committed Aug 25, 2023
1 parent 724f159 commit 587e6a4
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions tests/unit/components/NcAppSidebar/NcAppSidebarTabs.spec.js
Expand Up @@ -63,8 +63,8 @@ describe('NcAppSidebarTabs.vue', () => {
expect(onWarning).toHaveBeenCalledTimes(0)
expect(consoleDebug).toHaveBeenCalledTimes(0)
})
it('does not display the nav element', () => {
expect(wrapper.find('nav').exists()).toBe(false)
it('does not display the tablist element', () => {
expect(wrapper.find('div[role="tablist"]').exists()).toBe(false)
})
})
describe('with div and secondary action', () => {
Expand All @@ -88,8 +88,8 @@ describe('NcAppSidebarTabs.vue', () => {
})
})

it('does not display the nav element', () => {
expect(wrapper.find('nav').exists()).toBe(false)
it('does not display the tablist element', () => {
expect(wrapper.find('div[role="tablist"]').exists()).toBe(false)
})
})
describe('when only children of type AppSidebarTab is used', () => {
Expand All @@ -113,25 +113,25 @@ describe('NcAppSidebarTabs.vue', () => {
it('Issues no warning.', () => {
expect(onWarning).toHaveBeenCalledTimes(0)
})
it('display the nav element', () => {
expect(wrapper.find('nav').exists()).toBe(true)
it('display the tablist element', () => {
expect(wrapper.find('div[role="tablist"]').exists()).toBe(true)
})
it('display all the 3 elements', () => {
const liList = wrapper.findAll('nav>.checkbox-radio-switch')
const liList = wrapper.findAll('div[role="tablist"]>.checkbox-radio-switch')
expect(liList.length).toEqual(3)
})
it('emit "update:active" event with the selected tab id when clicking on a tab', () => {
const lastLink = wrapper.find('nav>.checkbox-radio-switch:last-of-type>label')
const lastLink = wrapper.find('div[role="tablist"]>.checkbox-radio-switch:last-of-type>label')
lastLink.trigger('click')
expect(wrapper.emitted('update:active')[0]).toEqual(['last'])
})
it('emit "update:active" event with the first tab id when keydown pageup is pressed', () => {
const lastLink = wrapper.find('nav>.checkbox-radio-switch:last-of-type>label')
const lastLink = wrapper.find('div[role="tablist"]>.checkbox-radio-switch:last-of-type>label')
lastLink.trigger('keydown.pageup')
expect(wrapper.emitted('update:active')[0]).toEqual(['first'])
})
it('emit "update:active" event with the last tab id when keydown pagedown is pressed', () => {
const lastLink = wrapper.find('nav>.checkbox-radio-switch:last-of-type>label')
const lastLink = wrapper.find('div[role="tablist"]>.checkbox-radio-switch:last-of-type>label')
lastLink.trigger('keydown.pagedown')
expect(wrapper.emitted('update:active')[0]).toEqual(['last'])
})
Expand All @@ -141,12 +141,12 @@ describe('NcAppSidebarTabs.vue', () => {
})
it('does not emit "update:active" event when keydown left is pressed', () => {
expect(wrapper.emitted('update:active')).toBeFalsy()
const firstLink = wrapper.find('nav>.checkbox-radio-switch>label')
const firstLink = wrapper.find('div[role="tablist"]>.checkbox-radio-switch>label')
firstLink.trigger('keydown.left')
expect(wrapper.emitted('update:active')).toBeFalsy()
})
it('emit "update:active" event with the next tab id when keydown right is pressed', () => {
const firstLink = wrapper.find('nav>.checkbox-radio-switch>label')
const firstLink = wrapper.find('div[role="tablist"]>.checkbox-radio-switch>label')
firstLink.trigger('keydown.right')
expect(wrapper.emitted('update:active')[0]).toEqual(['second'])
})
Expand All @@ -156,13 +156,13 @@ describe('NcAppSidebarTabs.vue', () => {
wrapper.setData({ activeTab: 'last' })
})
it('emit "update:active" event with the previous tab id when keydown left is pressed', () => {
const lastLink = wrapper.find('nav>.checkbox-radio-switch:last-of-type>label')
const lastLink = wrapper.find('div[role="tablist"]>.checkbox-radio-switch:last-of-type>label')
lastLink.trigger('keydown.left')
expect(wrapper.emitted('update:active')[0]).toEqual(['second'])
})
it('does not emit "update:active" event when keydown right is pressed', () => {
expect(wrapper.emitted('update:active')).toBeFalsy()
const lastLink = wrapper.find('nav>.checkbox-radio-switch:last-of-type>label')
const lastLink = wrapper.find('div[role="tablist"]>.checkbox-radio-switch:last-of-type>label')
lastLink.trigger('keydown.right')
expect(wrapper.emitted('update:active')).toBeFalsy()
})
Expand All @@ -185,8 +185,8 @@ describe('NcAppSidebarTabs.vue', () => {
it('Issues no warning.', () => {
expect(onWarning).toHaveBeenCalledTimes(0)
})
it('does not display the nav element', () => {
expect(wrapper.find('nav').exists()).toBe(false)
it('does not display the tablist element', () => {
expect(wrapper.find('div[role="tablist"]').exists()).toBe(false)
})
})
})
Expand Down

0 comments on commit 587e6a4

Please sign in to comment.