2021-02-22 20:26:38 +01:00
|
|
|
import { mount } from '@vue/test-utils'
|
2021-03-23 19:26:50 +01:00
|
|
|
import { Smile } from '../src/icons'
|
2021-02-22 20:26:38 +01:00
|
|
|
|
|
|
|
|
describe('Using lucide icon components', () => {
|
|
|
|
|
it('should render an component', () => {
|
|
|
|
|
const wrapper = mount(Smile)
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should adjust the size, stroke color and stroke width', () => {
|
|
|
|
|
const wrapper = mount(Smile, {
|
|
|
|
|
propsData: {
|
|
|
|
|
size: 48,
|
|
|
|
|
stroke: 'red',
|
|
|
|
|
strokeWidth: 4
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should add a class to the element', () => {
|
|
|
|
|
const wrapper = mount(Smile, {
|
|
|
|
|
attrs: {
|
|
|
|
|
class: "my-icon"
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
2021-09-17 15:51:18 +02:00
|
|
|
expect(String(wrapper.classes())).toBe(String(['lucide-icon','lucide','lucide-smile', 'my-icon']))
|
2021-02-22 20:26:38 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should add a style attribute to the element', () => {
|
|
|
|
|
const wrapper = mount(Smile, {
|
|
|
|
|
attrs: {
|
|
|
|
|
style: 'position: absolute',
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
|
expect(wrapper.attributes('style')).toContain('position: absolute')
|
|
|
|
|
});
|
2021-09-20 08:33:32 +02:00
|
|
|
|
|
|
|
|
it('should call the onClick event', () => {
|
|
|
|
|
const onClick = jest.fn()
|
|
|
|
|
const wrapper = mount(Smile, {
|
|
|
|
|
listeners: {
|
|
|
|
|
click: onClick
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
wrapper.trigger('click')
|
|
|
|
|
expect(onClick).toHaveBeenCalled()
|
|
|
|
|
});
|
2021-02-22 20:26:38 +01:00
|
|
|
});
|