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
87 lines (67 loc) • 2.14 kB
JavaScript
import { mount } from '@vue/test-utils'
import { IconsPlugin } from '../../icons'
import { Vue } from '../../vue'
import { BSkeletonIcon } from './skeleton-icon'
Vue.use(IconsPlugin)
describe('skeleton-icon', () => {
it('root element is DIV and contains SVG', async () => {
const wrapper = mount(BSkeletonIcon)
expect(wrapper).toBeDefined()
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.find('svg').exists()).toBe(true)
wrapper.destroy()
})
it('default animation is `wave`', async () => {
const wrapper = mount(BSkeletonIcon)
expect(wrapper).toBeDefined()
expect(wrapper.classes()).toContain('b-skeleton-animate-wave')
wrapper.destroy()
})
it('has class `b-skeleton-animate-fade` when `animation="fade"` is set', async () => {
const wrapper = mount(BSkeletonIcon, {
propsData: {
animation: 'fade'
}
})
expect(wrapper).toBeDefined()
expect(wrapper.classes()).toContain('b-skeleton-animate-fade')
wrapper.destroy()
})
it('`icon` prop works', async () => {
const wrapper = mount(BSkeletonIcon, {
propsData: {
icon: 'heart'
}
})
expect(wrapper).toBeDefined()
expect(wrapper.find('svg').exists()).toBe(true)
expect(wrapper.find('svg').classes()).toContain('bi-heart')
wrapper.destroy()
})
it('`icon-props` is passed correctly to icon', async () => {
const wrapper = mount(BSkeletonIcon, {
propsData: {
icon: 'heart',
iconProps: {
fontScale: 2,
variant: 'primary'
}
}
})
expect(wrapper).toBeDefined()
expect(wrapper.find('svg').exists()).toBe(true)
expect(wrapper.find('svg').classes()).toContain('text-primary')
expect(wrapper.find('svg').element.style.fontSize).toBe('200%')
wrapper.destroy()
})
it('accepts custom classes', async () => {
const wrapper = mount(BSkeletonIcon, {
context: {
class: ['foobar']
}
})
expect(wrapper.classes()).toContain('b-skeleton-icon-wrapper')
expect(wrapper.classes()).toContain('foobar')
wrapper.destroy()
})
})