bootstrap-vue
Version:
With more than 85 components, over 45 available plugins, several directives, and 1000+ icons, BootstrapVue provides one of the most comprehensive implementations of the Bootstrap v4 component and grid system available for Vue.js v2.6, complete with extens
49 lines (41 loc) • 1.33 kB
JavaScript
import { mount } from '@vue/test-utils'
import { BSkeletonWrapper } from './skeleton-wrapper'
describe('skeleton-wrapper', () => {
it('`loading` slot renders when `loading` prop is true', async () => {
const wrapper = mount(BSkeletonWrapper, {
propsData: {
loading: true
},
slots: {
loading: '<span>Loading state</span>'
}
})
expect(wrapper).toBeDefined()
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('b-skeleton-wrapper')
expect(wrapper.find('span').exists()).toBe(true)
expect(wrapper.find('span').text()).toBe('Loading state')
wrapper.destroy()
})
it('`default` slot renders when `loading` prop is false', async () => {
const wrapper = mount(BSkeletonWrapper, {
propsData: {
loading: false
},
slots: {
default: '<button>Action</button>'
}
})
expect(wrapper.find('button').text()).toBe('Action')
})
it('root element has correct aria attributes in loading state', async () => {
const wrapper = mount(BSkeletonWrapper, {
propsData: {
loading: true
}
})
expect(wrapper.attributes('aria-busy')).toBe('true')
expect(wrapper.attributes('aria-live')).toBe('polite')
expect(wrapper.attributes('role')).toBe('alert')
})
})