Skip to content

Commit

Permalink
test: render all icons
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Apr 5, 2019
1 parent d8a8617 commit 17f99d2
Showing 1 changed file with 22 additions and 25 deletions.
47 changes: 22 additions & 25 deletions tests/unit/Unicon.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { shallowMount } from '@vue/test-utils'
import { Unicon } from '../../src/components'
import { uniConstructor } from '../../src/icons'
import * as icons from '../../src/icons'

Unicon.add([uniConstructor])
Unicon.add(Object.values({ ...icons }))

const baseProps = {
name: 'constructor',
Expand All @@ -12,30 +12,27 @@ const baseProps = {
}

describe('Unicon', () => {
it('is rendered with props', () => {
const wrapper = shallowMount(Unicon, {
propsData: baseProps
})
expect(wrapper.exists()).toBe(true)
expect(wrapper.props().name).toBe('constructor')
expect(wrapper.props().width).toBe('20')
expect(wrapper.props().height).toBe('20')
expect(wrapper.props().fill).toBe('limegreen')
})
it('is rendered with dimensions', () => {
const wrapper = shallowMount(Unicon, {
propsData: baseProps
})
const svg = wrapper.find('svg')
expect(svg.attributes().width).toBe('20')
expect(svg.attributes().height).toBe('20')
})
it('is rendered with color', () => {
const wrapper = shallowMount(Unicon, {
propsData: baseProps
it('is all rendered', () => {
Object.values(icons).forEach(icon => {
const wrapper = shallowMount(Unicon, {
propsData: {
name: icon.name,
width: '20',
height: '20',
fill: 'limegreen'
}
})
const svg = wrapper.find('svg')

expect(wrapper.exists()).toBe(true)
expect(wrapper.props().name).toBe(icon.name)
expect(wrapper.props().width).toBe('20')
expect(wrapper.props().height).toBe('20')
expect(wrapper.props().fill).toBe('limegreen')
expect(svg.attributes().fill).toBe('limegreen')
expect(svg.attributes().width).toBe('20')
expect(svg.attributes().height).toBe('20')
})
const svg = wrapper.find('svg')
expect(svg.attributes().fill).toBe('limegreen')
})
it('click event is emitted', () => {
const wrapper = shallowMount(Unicon, {
Expand Down

0 comments on commit 17f99d2

Please sign in to comment.