mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-12-21 04:50:14 +08:00
test(NSpin): add spin test (#808)
This commit is contained in:
parent
aeb4f553ab
commit
018688cef1
@ -8,6 +8,21 @@ describe('n-spin', () => {
|
|||||||
it('should work with import on demand', () => {
|
it('should work with import on demand', () => {
|
||||||
mount(NSpin)
|
mount(NSpin)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should work with `show` prop', async () => {
|
||||||
|
const wrapper = mount(NSpin, {
|
||||||
|
props: {
|
||||||
|
show: true
|
||||||
|
},
|
||||||
|
slots: {
|
||||||
|
default: () => 'test'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
expect(wrapper.find('.n-spin-content').classes()).toContain(
|
||||||
|
'n-spin-content--spinning'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
it('should work with icon slot', () => {
|
it('should work with icon slot', () => {
|
||||||
const wrapper = mount(NSpin, {
|
const wrapper = mount(NSpin, {
|
||||||
slots: {
|
slots: {
|
||||||
@ -21,6 +36,7 @@ describe('n-spin', () => {
|
|||||||
expect(wrapper.findComponent(NIcon).exists()).toBe(true)
|
expect(wrapper.findComponent(NIcon).exists()).toBe(true)
|
||||||
expect(wrapper.findComponent(Reload).exists()).toBe(true)
|
expect(wrapper.findComponent(Reload).exists()).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('rotate should work on icon slot', async () => {
|
it('rotate should work on icon slot', async () => {
|
||||||
const wrapper = mount(NSpin, {
|
const wrapper = mount(NSpin, {
|
||||||
slots: {
|
slots: {
|
||||||
@ -36,4 +52,25 @@ describe('n-spin', () => {
|
|||||||
})
|
})
|
||||||
expect(wrapper.find('.n-spin--rotate').exists()).toBe(false)
|
expect(wrapper.find('.n-spin--rotate').exists()).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should work with `size` prop', async () => {
|
||||||
|
;(['small', 'medium', 'large', 71] as const).forEach((item) => {
|
||||||
|
const wrapper = mount(NSpin, {
|
||||||
|
props: {
|
||||||
|
size: item
|
||||||
|
}
|
||||||
|
})
|
||||||
|
expect(wrapper.find('.n-spin').attributes('style')).toMatchSnapshot()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should work with `default` slot', async () => {
|
||||||
|
const wrapper = mount(NSpin, {
|
||||||
|
slots: {
|
||||||
|
default: () => 'test'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
expect(wrapper.find('.n-spin-container').exists()).toBe(true)
|
||||||
|
expect(wrapper.find('.n-spin-content').text()).toBe('test')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
9
src/spin/tests/__snapshots__/Spin.spec.ts.snap
Normal file
9
src/spin/tests/__snapshots__/Spin.spec.ts.snap
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`n-spin should work with \`size\` prop 1`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 28px; --color: #18a058;"`;
|
||||||
|
|
||||||
|
exports[`n-spin should work with \`size\` prop 2`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 34px; --color: #18a058;"`;
|
||||||
|
|
||||||
|
exports[`n-spin should work with \`size\` prop 3`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 40px; --color: #18a058;"`;
|
||||||
|
|
||||||
|
exports[`n-spin should work with \`size\` prop 4`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 71px; --color: #18a058;"`;
|
Loading…
Reference in New Issue
Block a user