mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
test(NResult): add test (#773)
This commit is contained in:
parent
05ef8cba49
commit
12946303e9
@ -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')
|
||||
})
|
||||
})
|
||||
|
9
src/result/tests/__snapshots__/Result.spec.ts.snap
Normal file
9
src/result/tests/__snapshots__/Result.spec.ts.snap
Normal 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;"`;
|
Loading…
Reference in New Issue
Block a user