Files
react/components/card/__tests__/index.test.tsx
2020-04-16 10:12:28 +08:00

49 lines
1.2 KiB
TypeScript

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()
})
})