test(NSpin): add spin test (#808)

This commit is contained in:
XieZongChen 2021-08-07 10:00:02 -05:00 committed by GitHub
parent aeb4f553ab
commit 018688cef1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View File

@ -8,6 +8,21 @@ describe('n-spin', () => {
it('should work with import on demand', () => {
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', () => {
const wrapper = mount(NSpin, {
slots: {
@ -21,6 +36,7 @@ describe('n-spin', () => {
expect(wrapper.findComponent(NIcon).exists()).toBe(true)
expect(wrapper.findComponent(Reload).exists()).toBe(true)
})
it('rotate should work on icon slot', async () => {
const wrapper = mount(NSpin, {
slots: {
@ -36,4 +52,25 @@ describe('n-spin', () => {
})
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')
})
})

View 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;"`;