test(NSkeleton): add test (#804)

This commit is contained in:
XieZongChen 2021-08-06 09:35:45 -05:00 committed by GitHub
parent 648392b8c4
commit 9c187b9c1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,58 @@
import { mount } from '@vue/test-utils'
import { NSkeleton } from '../index'
describe('n-skeleton', () => {
it('should work with import on demand', () => {
mount(NSkeleton)
})
it('should work with `text` prop', async () => {
const wrapper = mount(NSkeleton, {
props: {
text: true
}
})
expect(wrapper.find('.n-skeleton').attributes('style')).toMatchSnapshot()
})
it('should work with box', async () => {
const wrapper = mount(NSkeleton)
expect(wrapper.find('.n-skeleton').attributes('style')).toMatchSnapshot()
})
it('should work with `sharp` prop', async () => {
const wrapper = mount(NSkeleton, {
props: {
sharp: false
}
})
expect(wrapper.find('.n-skeleton').attributes('style')).toMatchSnapshot()
})
it('should work with `round` prop', async () => {
const wrapper = mount(NSkeleton, {
props: {
round: true
}
})
expect(wrapper.find('.n-skeleton').attributes('style')).toMatchSnapshot()
})
it('should work with `circle` prop', async () => {
const wrapper = mount(NSkeleton, {
props: {
circle: true
}
})
expect(wrapper.find('.n-skeleton').attributes('style')).toMatchSnapshot()
})
it('should work with `repeat` prop', async () => {
const wrapper = mount(NSkeleton, {
props: {
repeat: 2
}
})
expect(wrapper.findAll('.n-skeleton').length).toBe(2)
})
})

View File

@ -0,0 +1,11 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`n-skeleton should work with \`circle\` prop 1`] = `"border-radius: 50%; --bezier: cubic-bezier(.4, 0, .2, 1); --color-start: #eee; --color-end: #ddd;"`;
exports[`n-skeleton should work with \`round\` prop 1`] = `"border-radius: 4096px; --bezier: cubic-bezier(.4, 0, .2, 1); --color-start: #eee; --color-end: #ddd;"`;
exports[`n-skeleton should work with \`sharp\` prop 1`] = `"border-radius: 3px; --bezier: cubic-bezier(.4, 0, .2, 1); --color-start: #eee; --color-end: #ddd;"`;
exports[`n-skeleton should work with \`text\` prop 1`] = `"display: inline-block; vertical-align: -0.125em; --bezier: cubic-bezier(.4, 0, .2, 1); --color-start: #eee; --color-end: #ddd;"`;
exports[`n-skeleton should work with box 1`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --color-start: #eee; --color-end: #ddd;"`;