mirror of
https://github.com/zhigang1992/react.git
synced 2026-04-25 21:05:36 +08:00
style(prettier): format code style
This commit is contained in:
@@ -8,7 +8,7 @@ describe('Button', () => {
|
||||
const wrapper = mount(<Button>Button</Button>)
|
||||
expect(() => wrapper.unmount()).not.toThrow()
|
||||
})
|
||||
|
||||
|
||||
it('should support all types', () => {
|
||||
const wrapper = mount(
|
||||
<div>
|
||||
@@ -17,11 +17,11 @@ describe('Button', () => {
|
||||
<Button type="warning" />
|
||||
<Button type="error" />
|
||||
<Button type="abort" />
|
||||
</div>
|
||||
</div>,
|
||||
)
|
||||
expect(() => wrapper.unmount()).not.toThrow()
|
||||
})
|
||||
|
||||
|
||||
it('should support all sizes', () => {
|
||||
const wrapper = mount(
|
||||
<div>
|
||||
@@ -29,41 +29,37 @@ describe('Button', () => {
|
||||
<Button size="small" />
|
||||
<Button size="medium" />
|
||||
<Button size="large" />
|
||||
</div>
|
||||
</div>,
|
||||
)
|
||||
expect(() => wrapper.unmount()).not.toThrow()
|
||||
})
|
||||
|
||||
|
||||
it('should render different text', () => {
|
||||
const wrapper = mount(<Button>button</Button>)
|
||||
expect(wrapper.text()).toContain('button')
|
||||
|
||||
|
||||
wrapper.setProps({
|
||||
children: <span>按钮</span>,
|
||||
})
|
||||
expect(wrapper.text()).toContain('按钮')
|
||||
})
|
||||
|
||||
|
||||
it('should render empty button correctly', () => {
|
||||
expect(<Button></Button>).toMatchSnapshot()
|
||||
})
|
||||
|
||||
|
||||
it('should trigger callback function', () => {
|
||||
const WrapperButton = () => {
|
||||
const [state, setState] = React.useState<string>('state1')
|
||||
return (
|
||||
<Button onClick={() => setState('state2')}>
|
||||
{state}
|
||||
</Button>
|
||||
)
|
||||
return <Button onClick={() => setState('state2')}>{state}</Button>
|
||||
}
|
||||
const wrapper = mount(<WrapperButton />)
|
||||
expect(wrapper.text()).toContain('state1')
|
||||
|
||||
|
||||
wrapper.simulate('click')
|
||||
expect(wrapper.text()).toContain('state2')
|
||||
})
|
||||
|
||||
|
||||
it('should ignore events when disabled', () => {
|
||||
const WrapperButton = () => {
|
||||
const [state, setState] = React.useState<string>('state1')
|
||||
@@ -75,12 +71,12 @@ describe('Button', () => {
|
||||
}
|
||||
const wrapper = mount(<WrapperButton />)
|
||||
expect(wrapper.text()).toContain('state1')
|
||||
|
||||
|
||||
wrapper.simulate('click')
|
||||
expect(wrapper.text()).toContain('state1')
|
||||
expect(wrapper.text()).not.toContain('state2')
|
||||
})
|
||||
|
||||
|
||||
it('should ignore events when loading', () => {
|
||||
const WrapperButton = () => {
|
||||
const [state, setState] = React.useState<string>('state1')
|
||||
@@ -94,29 +90,35 @@ describe('Button', () => {
|
||||
wrapper.simulate('click')
|
||||
expect(wrapper.text()).not.toContain('state2')
|
||||
})
|
||||
|
||||
|
||||
it('should render special styles', () => {
|
||||
const wrapper = mount(
|
||||
<div>
|
||||
<Button ghost>button</Button>
|
||||
<Button ghost type="success">button</Button>
|
||||
<Button ghost type="warning">button</Button>
|
||||
<Button ghost loading>button</Button>
|
||||
<Button ghost type="success">
|
||||
button
|
||||
</Button>
|
||||
<Button ghost type="warning">
|
||||
button
|
||||
</Button>
|
||||
<Button ghost loading>
|
||||
button
|
||||
</Button>
|
||||
<Button shadow>button</Button>
|
||||
<Button auto>button</Button>
|
||||
<Button effect={false}>button</Button>
|
||||
</div>
|
||||
</div>,
|
||||
)
|
||||
expect(wrapper).toMatchSnapshot()
|
||||
expect(<Button loading>button</Button>).toMatchSnapshot()
|
||||
})
|
||||
|
||||
|
||||
it('should remove expired events', () => {
|
||||
const wrapper = mount(<Button>button</Button>)
|
||||
wrapper.simulate('click')
|
||||
expect(() => wrapper.unmount()).not.toThrow()
|
||||
})
|
||||
|
||||
|
||||
it('should support loading change with deply', async () => {
|
||||
const wrapper = mount(<Button>button</Button>)
|
||||
wrapper.simulate('click')
|
||||
|
||||
Reference in New Issue
Block a user