mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
by setting up localVue with all required plugins (such as styleguide and vuex) in a separate testSetup file we can avoid doing this individually in all component tests the testSetup is executed before each test suite, so each test file gets a fresh instance of localVue
54 lines
1.4 KiB
JavaScript
54 lines
1.4 KiB
JavaScript
import { shallowMount } from '@vue/test-utils'
|
|
|
|
import Empty from './Empty.vue'
|
|
|
|
const localVue = global.localVue
|
|
|
|
describe('Empty.vue', () => {
|
|
let propsData, wrapper
|
|
|
|
beforeEach(() => {
|
|
propsData = {}
|
|
})
|
|
|
|
const Wrapper = () => {
|
|
return shallowMount(Empty, { propsData, localVue })
|
|
}
|
|
|
|
describe('shallowMount', () => {
|
|
beforeEach(() => {
|
|
wrapper = Wrapper()
|
|
})
|
|
|
|
it('renders an image with an alert icon as default', () => {
|
|
expect(wrapper.find('img[alt="Empty"]').attributes().src).toBe('/img/empty/alert.svg')
|
|
})
|
|
|
|
describe('receives icon prop', () => {
|
|
it('renders an image with that icon', () => {
|
|
propsData.icon = 'messages'
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('img[alt="Empty"]').attributes().src).toBe(
|
|
`/img/empty/${propsData.icon}.svg`,
|
|
)
|
|
})
|
|
})
|
|
|
|
describe('receives message prop', () => {
|
|
it('renders that message', () => {
|
|
propsData.message = 'this is a custom message for Empty component'
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('.hc-empty-message').text()).toEqual(propsData.message)
|
|
})
|
|
})
|
|
|
|
describe('receives margin prop', () => {
|
|
it('sets margin to that margin', () => {
|
|
propsData.margin = 'xxx-small'
|
|
wrapper = Wrapper()
|
|
expect(wrapper.find('.hc-empty').attributes().margin).toEqual(propsData.margin)
|
|
})
|
|
})
|
|
})
|
|
})
|