mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2025-01-06 12:17:13 +08:00
test(gradient-text): add gradient-text test (#368)
* test(gradient-text): add gradient-text test * test: optimization * test: optimization
This commit is contained in:
parent
0c2489e0a2
commit
47a67a2da2
@ -5,4 +5,57 @@ describe('n-gradient-text', () => {
|
||||
it('should work with import on demand', () => {
|
||||
mount(NGradientText)
|
||||
})
|
||||
|
||||
it('should work with `type` prop', async () => {
|
||||
const wrapper = mount(NGradientText, { slots: { default: () => 'test' } })
|
||||
expect(wrapper.find('.n-gradient-text').text()).toContain('test')
|
||||
|
||||
const typeArray = [
|
||||
'error',
|
||||
'info',
|
||||
'warning',
|
||||
'success',
|
||||
'primary'
|
||||
] as const
|
||||
typeArray.forEach((item) => {
|
||||
const wrapper = mount(NGradientText, {
|
||||
props: { type: item },
|
||||
slots: { default: () => 'test' }
|
||||
})
|
||||
expect(wrapper.find('.n-gradient-text').classes()).toContain(
|
||||
`n-gradient-text--${item}-type`
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
it('should work with `size` prop', async () => {
|
||||
const wrapper = mount(NGradientText, { slots: { default: () => 'test' } })
|
||||
expect(wrapper.find('.n-gradient-text').attributes('style')).not.toContain(
|
||||
'font-size'
|
||||
)
|
||||
|
||||
await wrapper.setProps({ size: '24' })
|
||||
expect(wrapper.find('.n-gradient-text').attributes('style')).toContain(
|
||||
'font-size: 24px;'
|
||||
)
|
||||
})
|
||||
|
||||
it('should work with `gradient` prop', async () => {
|
||||
const wrapper = mount(NGradientText, { slots: { default: () => 'test' } })
|
||||
|
||||
await wrapper.setProps({
|
||||
gradient:
|
||||
"{ deg: 180, from: 'rgb(85, 85, 85)', to: 'rgb(170, 170, 170)' }"
|
||||
})
|
||||
expect(
|
||||
wrapper.find('.n-gradient-text').attributes('style')
|
||||
).toMatchSnapshot()
|
||||
|
||||
await wrapper.setProps({
|
||||
gradient: 'linear-gradient(90deg, red 0%, green 50%, blue 100%)'
|
||||
})
|
||||
expect(
|
||||
wrapper.find('.n-gradient-text').attributes('style')
|
||||
).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
|
@ -0,0 +1,5 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`n-gradient-text should work with \`gradient\` prop 1`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --rotate: 252deg; --color-start: rgba(24, 160, 88, 0.6); --color-end: #18a058; --font-weight: 500;"`;
|
||||
|
||||
exports[`n-gradient-text should work with \`gradient\` prop 2`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --rotate: 252deg; --color-start: rgba(24, 160, 88, 0.6); --color-end: #18a058; --font-weight: 500;"`;
|
Loading…
Reference in New Issue
Block a user