mirror of
https://github.com/Ocelot-Social-Community/Ocelot-Social.git
synced 2025-12-13 07:46:06 +00:00
Add component test for Empty.vue
This commit is contained in:
parent
1d8e328a47
commit
6fca753c1f
54
webapp/components/Empty/Empty.spec.js
Normal file
54
webapp/components/Empty/Empty.spec.js
Normal file
@ -0,0 +1,54 @@
|
||||
import { shallowMount, createLocalVue } from '@vue/test-utils'
|
||||
import Styleguide from '@human-connection/styleguide'
|
||||
import Empty from './Empty.vue'
|
||||
|
||||
const localVue = createLocalVue()
|
||||
localVue.use(Styleguide)
|
||||
|
||||
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)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user