test(card): add testcase

This commit is contained in:
unix
2020-04-16 10:11:57 +08:00
parent 5383c695c1
commit aaa17db9c8
3 changed files with 2036 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
import React from 'react'
import { mount, render } from 'enzyme'
import { Card } from '../../index'
describe('Card', () => {
it('should render correctly', () => {
const wrapper = mount(<Card>card</Card>)
expect(() => wrapper.unmount()).not.toThrow()
})
it('should support shadow and hoverable', () => {
const wrapper = render(
<div>
<Card hoverable>card</Card>
<Card shadow>card</Card>
<Card shadow hoverable>card</Card>
</div>
)
expect(wrapper).toMatchSnapshot()
})
it('should support card types', () => {
const wrapper = mount(
<div>
<Card type="secondary">card</Card>
<Card type="success">card</Card>
<Card type="violet">card</Card>
<Card type="lite">card</Card>
<Card type="cyan">card</Card>
<Card type="secondary">card</Card>
<Card type="warning">card</Card>
</div>
)
expect(() => wrapper.unmount()).not.toThrow()
})
it('should render correctly when nested', () => {
const wrapper = render(
<Card>
<Card shadow>
<Card>card</Card>
</Card>
</Card>
)
expect(wrapper).toMatchSnapshot()
})
})

View File

@@ -1,5 +1,3 @@
import Card from './card'
import { CardProps } from './card'
export type Props = CardProps
export default Card