mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
test(button): optimization (#1187)
This commit is contained in:
parent
c1e2946b59
commit
ee0265a275
@ -37,22 +37,15 @@ describe('n-button', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should work with `type` prop', async () => {
|
it('should work with `type` prop', async () => {
|
||||||
const wrapper = mount(NButton)
|
;(['primary', 'info', 'success', 'warning', 'error'] as const).forEach(
|
||||||
|
(type) => {
|
||||||
await wrapper.setProps({ type: 'primary' })
|
const wrapper = mount(NButton, { props: { type: type } })
|
||||||
expect(wrapper.find('button').classes()).toContain('n-button--primary-type')
|
expect(wrapper.find('button').classes()).toContain(
|
||||||
|
`n-button--${type}-type`
|
||||||
await wrapper.setProps({ type: 'info' })
|
)
|
||||||
expect(wrapper.find('button').classes()).toContain('n-button--info-type')
|
wrapper.unmount()
|
||||||
|
}
|
||||||
await wrapper.setProps({ type: 'success' })
|
)
|
||||||
expect(wrapper.find('button').classes()).toContain('n-button--success-type')
|
|
||||||
|
|
||||||
await wrapper.setProps({ type: 'warning' })
|
|
||||||
expect(wrapper.find('button').classes()).toContain('n-button--warning-type')
|
|
||||||
|
|
||||||
await wrapper.setProps({ type: 'error' })
|
|
||||||
expect(wrapper.find('button').classes()).toContain('n-button--error-type')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should work with `dashed` prop', async () => {
|
it('should work with `dashed` prop', async () => {
|
||||||
@ -70,19 +63,11 @@ describe('n-button', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('should work with `size` prop', async () => {
|
it('should work with `size` prop', async () => {
|
||||||
const wrapper = mount(NButton)
|
;(['tiny', 'small', 'medium', 'large'] as const).forEach((size) => {
|
||||||
|
const wrapper = mount(NButton, { props: { size: size } })
|
||||||
await wrapper.setProps({ size: 'tiny' })
|
|
||||||
expect(wrapper.find('button').attributes('style')).toMatchSnapshot()
|
|
||||||
|
|
||||||
await wrapper.setProps({ size: 'small' })
|
|
||||||
expect(wrapper.find('button').attributes('style')).toMatchSnapshot()
|
|
||||||
|
|
||||||
await wrapper.setProps({ size: 'medium' })
|
|
||||||
expect(wrapper.find('button').attributes('style')).toMatchSnapshot()
|
|
||||||
|
|
||||||
await wrapper.setProps({ size: 'large' })
|
|
||||||
expect(wrapper.find('button').attributes('style')).toMatchSnapshot()
|
expect(wrapper.find('button').attributes('style')).toMatchSnapshot()
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should work with `text` prop', () => {
|
it('should work with `text` prop', () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user