diff --git a/src/spin/tests/Spin.spec.ts b/src/spin/tests/Spin.spec.ts index 95933908b..c080f00d0 100644 --- a/src/spin/tests/Spin.spec.ts +++ b/src/spin/tests/Spin.spec.ts @@ -8,6 +8,21 @@ describe('n-spin', () => { it('should work with import on demand', () => { mount(NSpin) }) + + it('should work with `show` prop', async () => { + const wrapper = mount(NSpin, { + props: { + show: true + }, + slots: { + default: () => 'test' + } + }) + expect(wrapper.find('.n-spin-content').classes()).toContain( + 'n-spin-content--spinning' + ) + }) + it('should work with icon slot', () => { const wrapper = mount(NSpin, { slots: { @@ -21,6 +36,7 @@ describe('n-spin', () => { expect(wrapper.findComponent(NIcon).exists()).toBe(true) expect(wrapper.findComponent(Reload).exists()).toBe(true) }) + it('rotate should work on icon slot', async () => { const wrapper = mount(NSpin, { slots: { @@ -36,4 +52,25 @@ describe('n-spin', () => { }) expect(wrapper.find('.n-spin--rotate').exists()).toBe(false) }) + + it('should work with `size` prop', async () => { + ;(['small', 'medium', 'large', 71] as const).forEach((item) => { + const wrapper = mount(NSpin, { + props: { + size: item + } + }) + expect(wrapper.find('.n-spin').attributes('style')).toMatchSnapshot() + }) + }) + + it('should work with `default` slot', async () => { + const wrapper = mount(NSpin, { + slots: { + default: () => 'test' + } + }) + expect(wrapper.find('.n-spin-container').exists()).toBe(true) + expect(wrapper.find('.n-spin-content').text()).toBe('test') + }) }) diff --git a/src/spin/tests/__snapshots__/Spin.spec.ts.snap b/src/spin/tests/__snapshots__/Spin.spec.ts.snap new file mode 100644 index 000000000..eecf8f27e --- /dev/null +++ b/src/spin/tests/__snapshots__/Spin.spec.ts.snap @@ -0,0 +1,9 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`n-spin should work with \`size\` prop 1`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 28px; --color: #18a058;"`; + +exports[`n-spin should work with \`size\` prop 2`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 34px; --color: #18a058;"`; + +exports[`n-spin should work with \`size\` prop 3`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 40px; --color: #18a058;"`; + +exports[`n-spin should work with \`size\` prop 4`] = `"--bezier: cubic-bezier(.4, 0, .2, 1); --opacity-spinning: 0.5; --size: 71px; --color: #18a058;"`;