Skip to content

Commit

Permalink
test(VDivider): update existing tests and expand coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
johnleider committed Jan 26, 2021
1 parent f0b181b commit 3e6a499
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions packages/vuetify/src/components/VDivider/__tests__/VDivider.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,47 @@ import VDivider from '../VDivider'
// Utilities
import { createTheme, VuetifyThemeSymbol } from '@/composables'
import { mount } from '@vue/test-utils'
import { nextTick } from 'vue'
import { VuetifySymbol } from '@/framework'

describe('VDivider', () => {
const provide: any = {
[VuetifySymbol as symbol]: { defaults: { global: {} } },
[VuetifyThemeSymbol as symbol]: createTheme(),
function mountFunction (options = {}) {
return mount(VDivider, {
global: {
provide: {
[VuetifySymbol as symbol]: { defaults: { global: {} } },
[VuetifyThemeSymbol as symbol]: createTheme(),
},
},
...options,
})
}

it('should match a snapshot', () => {
const wrapper = mount(VDivider, {
global: { provide },
})
const wrapper = mountFunction()

expect(wrapper.html()).toMatchSnapshot()
})

it('should have correct a11y attributes', async () => {
const wrapper = mount(VDivider, {
global: { provide },
})

expect(wrapper.attributes().ariaorientation).toBe('horizontal')
expect(wrapper.attributes().role).toBe('separator')
it.each([
[{ length: 256 }, 'max-width: 256px;'],
[{ length: '128', vertical: true }, 'max-height: 128px;'],
[{ thickness: 2 }, 'border-top-width: 2px;'],
[{ thickness: '5', vertical: true }, 'border-right-width: 5px;'],
])('should have correct styles for %s', (propsData, expected) => {
const wrapper = mountFunction({ propsData })

wrapper.setProps({ vertical: true })

await nextTick()

expect(wrapper.attributes().ariaorientation).toBe('vertical')
expect(wrapper.attributes().role).toBe('separator')

wrapper.setProps({ vertical: false, role: 'foo' })
expect(wrapper.attributes('style')).toEqual(expected)
})

await nextTick()
it.each([
[{}, ['horizontal', 'separator']],
[{ vertical: true }, ['vertical', 'separator']],
[{ role: 'foo' }, [undefined, 'foo']],
])('should have correct styles for %s', (propsData, expected) => {
const wrapper = mountFunction({ propsData })
const [ariaorientation, role] = expected

expect(wrapper.attributes().ariaorientation).toBeUndefined()
expect(wrapper.attributes().role).toBe('foo')
expect(wrapper.attributes().ariaorientation).toBe(ariaorientation)
expect(wrapper.attributes().role).toBe(role)
})
})

0 comments on commit 3e6a499

Please sign in to comment.