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
80 lines (64 loc) • 2.25 kB
JavaScript
import { mount } from '@vue/test-utils'
import { BMediaAside } from './media-aside'
describe('media-aside', () => {
it('has expected default structure', async () => {
const wrapper = mount(BMediaAside)
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('media-aside')
expect(wrapper.classes()).toContain('align-self-start')
expect(wrapper.text()).toEqual('')
wrapper.destroy()
})
it('has custom root element when prop `tag` set', async () => {
const wrapper = mount(BMediaAside, {
propsData: {
tag: 'span'
}
})
expect(wrapper.element.tagName).toBe('SPAN')
expect(wrapper.classes()).toContain('media-aside')
expect(wrapper.classes()).toContain('align-self-start')
expect(wrapper.classes().length).toBe(2)
expect(wrapper.text()).toEqual('')
wrapper.destroy()
})
it('has correct class when prop `right` set', async () => {
const wrapper = mount(BMediaAside, {
propsData: {
right: true
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('media-aside')
expect(wrapper.classes()).toContain('media-aside-right')
expect(wrapper.classes()).toContain('align-self-start')
expect(wrapper.classes().length).toBe(3)
wrapper.destroy()
})
it('has alignment class when prop `vertical-align` set', async () => {
const wrapper = mount(BMediaAside, {
propsData: {
verticalAlign: 'bottom'
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('media-aside')
expect(wrapper.classes()).toContain('align-self-end')
expect(wrapper.classes().length).toBe(2)
wrapper.destroy()
})
it('renders default slot content', async () => {
const wrapper = mount(BMediaAside, {
slots: {
default: '<b>foobar</b>'
}
})
expect(wrapper.element.tagName).toBe('DIV')
expect(wrapper.classes()).toContain('media-aside')
expect(wrapper.classes()).toContain('align-self-start')
expect(wrapper.classes().length).toBe(2)
expect(wrapper.findAll('b').length).toBe(1)
expect(wrapper.find('b').text()).toBe('foobar')
wrapper.destroy()
})
})