mirror of
https://github.com/zhigang1992/react.git
synced 2026-02-08 17:13:12 +08:00
test(tag): add testcase
This commit is contained in:
1705
components/tag/__tests__/__snapshots__/index.test.tsx.snap
Normal file
1705
components/tag/__tests__/__snapshots__/index.test.tsx.snap
Normal file
File diff suppressed because it is too large
Load Diff
32
components/tag/__tests__/index.test.tsx
Normal file
32
components/tag/__tests__/index.test.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from 'react'
|
||||
import { mount, render } from 'enzyme'
|
||||
import { Tag } from 'components'
|
||||
|
||||
describe('Tag', () => {
|
||||
it('should render correctly', () => {
|
||||
const wrapper = mount(<Tag>tag</Tag>)
|
||||
expect(() => wrapper.unmount()).not.toThrow()
|
||||
})
|
||||
|
||||
it('should work with types', () => {
|
||||
const wrapper = render(
|
||||
<div>
|
||||
<Tag type="success">success</Tag>
|
||||
<Tag type="secondary">secondary</Tag>
|
||||
<Tag type="error">error</Tag>
|
||||
<Tag type="dark">dark</Tag>
|
||||
</div>
|
||||
)
|
||||
expect(wrapper).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('should work with invert', () => {
|
||||
const wrapper = render(<Tag type="success" invert>success</Tag>)
|
||||
expect(wrapper).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('should work when child is null', () => {
|
||||
const wrapper = mount(<Tag />)
|
||||
expect(() => wrapper.unmount()).not.toThrow()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user