mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-27 19:25:05 +08:00
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import React from 'react'
|
|
import { mount, render } from 'enzyme'
|
|
import { Col } from 'components'
|
|
|
|
describe('Col', () => {
|
|
it('should render correctly', () => {
|
|
const wrapper = mount(<Col>col</Col>)
|
|
expect(wrapper).toMatchSnapshot()
|
|
expect(() => wrapper.unmount()).not.toThrow()
|
|
})
|
|
|
|
it('should work with span and offset', () => {
|
|
const wrapper = render(
|
|
<div>
|
|
<Col span={2}>col</Col>
|
|
<Col span={2} offset={2}>
|
|
col
|
|
</Col>
|
|
</div>,
|
|
)
|
|
expect(wrapper).toMatchSnapshot()
|
|
})
|
|
|
|
it('should render correctly when nested', () => {
|
|
const wrapper = mount(
|
|
<Col>
|
|
<Col>
|
|
<Col />
|
|
col
|
|
</Col>
|
|
</Col>,
|
|
)
|
|
expect(() => wrapper.unmount()).not.toThrow()
|
|
})
|
|
|
|
it('should render different components', () => {
|
|
let wrapper = mount(<Col component="p" />)
|
|
expect(wrapper.find('p').length).not.toBe(0)
|
|
|
|
wrapper = mount(<Col component="details" />)
|
|
expect(wrapper.find('details').length).not.toBe(0)
|
|
|
|
wrapper = mount(<Col component="h1" />)
|
|
expect(wrapper.find('h1').length).not.toBe(0)
|
|
})
|
|
})
|