test(NResult): add test (#773)

This commit is contained in:
XieZongChen 2021-08-04 01:28:49 -05:00 committed by GitHub
parent 05ef8cba49
commit 12946303e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 0 deletions

View File

@ -5,4 +5,41 @@ describe('n-result', () => {
it('should work with import on demand', () => {
mount(NResult)
})
it('should work with `description` prop', async () => {
const wrapper = mount(NResult, {
props: { description: 'test-description' }
})
expect(wrapper.find('.n-result-header__description').exists()).toBe(true)
expect(wrapper.find('.n-result-header__description').text()).toBe(
'test-description'
)
})
it('should work with `title` prop', async () => {
const wrapper = mount(NResult, {
props: { title: 'test-title' }
})
expect(wrapper.find('.n-result-header__title').exists()).toBe(true)
expect(wrapper.find('.n-result-header__title').text()).toBe('test-title')
})
it('should work with `size` prop', async () => {
;(['small', 'medium', 'large', 'huge'] as const).forEach((item) => {
const wrapper = mount(NResult, {
props: { size: item }
})
expect(wrapper.find('.n-result').attributes('style')).toMatchSnapshot()
})
})
it('should work with slots', async () => {
const wrapper = mount(NResult, {
slots: { default: () => 'test-default', footer: () => 'test-footer' }
})
expect(wrapper.find('.n-result-content').exists()).toBe(true)
expect(wrapper.find('.n-result-content').text()).toBe('test-default')
expect(wrapper.find('.n-result-footer').exists()).toBe(true)
expect(wrapper.find('.n-result-footer').text()).toBe('test-footer')
})
})

View File

@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`n-result should work with \`size\` prop 1`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --font-size: 14px; --icon-size: 64px; --line-height: 1.6; --text-color: rgb(51, 54, 57); --title-font-size: 26px; --title-font-weight: 500; --title-text-color: rgb(31, 34, 37); --icon-color: #2080f0;"`;
exports[`n-result should work with \`size\` prop 2`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --font-size: 14px; --icon-size: 80px; --line-height: 1.6; --text-color: rgb(51, 54, 57); --title-font-size: 32px; --title-font-weight: 500; --title-text-color: rgb(31, 34, 37); --icon-color: #2080f0;"`;
exports[`n-result should work with \`size\` prop 3`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --font-size: 15px; --icon-size: 100px; --line-height: 1.6; --text-color: rgb(51, 54, 57); --title-font-size: 40px; --title-font-weight: 500; --title-text-color: rgb(31, 34, 37); --icon-color: #2080f0;"`;
exports[`n-result should work with \`size\` prop 4`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --font-size: 16px; --icon-size: 125px; --line-height: 1.6; --text-color: rgb(51, 54, 57); --title-font-size: 48px; --title-font-weight: 500; --title-text-color: rgb(31, 34, 37); --icon-color: #2080f0;"`;