diff --git a/src/gradient-text/tests/GradientText.spec.ts b/src/gradient-text/tests/GradientText.spec.ts index 072bb0450..c8ac4692c 100644 --- a/src/gradient-text/tests/GradientText.spec.ts +++ b/src/gradient-text/tests/GradientText.spec.ts @@ -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() + }) }) diff --git a/src/gradient-text/tests/__snapshots__/GradientText.spec.ts.snap b/src/gradient-text/tests/__snapshots__/GradientText.spec.ts.snap new file mode 100644 index 000000000..5adbee8f1 --- /dev/null +++ b/src/gradient-text/tests/__snapshots__/GradientText.spec.ts.snap @@ -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;"`;