mirror of
https://github.com/zhigang1992/react.git
synced 2026-03-26 06:55:07 +08:00
test(user): add testcase
This commit is contained in:
4159
components/user/__tests__/__snapshots__/index.test.tsx.snap
Normal file
4159
components/user/__tests__/__snapshots__/index.test.tsx.snap
Normal file
File diff suppressed because it is too large
Load Diff
35
components/user/__tests__/index.test.tsx
Normal file
35
components/user/__tests__/index.test.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import React from 'react'
|
||||
import { mount, render } from 'enzyme'
|
||||
import { User } from '../../index'
|
||||
|
||||
describe(' User', () => {
|
||||
it('should render correctly', () => {
|
||||
const wrapper = mount(<User name="witt" />)
|
||||
expect(() => wrapper.unmount()).not.toThrow()
|
||||
})
|
||||
|
||||
it('should support image and text', () => {
|
||||
const wrapper = render(
|
||||
<div>
|
||||
<User name="witt" text="witt" />
|
||||
<User name="witt" src="https://unix.bio/assets/avatar.png" />
|
||||
</div>
|
||||
)
|
||||
expect(wrapper).toMatchSnapshot()
|
||||
})
|
||||
|
||||
it('should render description correctly', () => {
|
||||
const wrapper = mount(<User name="witt">description</User>)
|
||||
expect(wrapper.text().toLowerCase()).toContain('description')
|
||||
})
|
||||
|
||||
it('should render link on user.link', () => {
|
||||
const wrapper = mount(
|
||||
<User name="witt">
|
||||
<User.Link href="https://twitter.com/echo_witt">twitter</User.Link>
|
||||
</User>
|
||||
)
|
||||
const link = wrapper.find('a')
|
||||
expect(link.length).not.toBe(0)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user