diff --git a/src/skeleton/test/__snapshots__/index.legacy.js.snap b/src/skeleton/test/__snapshots__/index.legacy.js.snap deleted file mode 100644 index 0ffcccc95..000000000 --- a/src/skeleton/test/__snapshots__/index.legacy.js.snap +++ /dev/null @@ -1,38 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`avatar shape 1`] = ` -
-
-
-
-`; - -exports[`disable animate 1`] = ` -
-
-
-
-
-`; - -exports[`render chidren 1`] = `
Content
`; - -exports[`round prop 1`] = ` -
-
-
-

-
-
-`; - -exports[`row-width array 1`] = ` -
-
-
-
-
-
-
-
-`; diff --git a/src/skeleton/test/__snapshots__/index.spec.js.snap b/src/skeleton/test/__snapshots__/index.spec.js.snap new file mode 100644 index 000000000..8a864ef96 --- /dev/null +++ b/src/skeleton/test/__snapshots__/index.spec.js.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should change avatar shape when using avatar-shape prop 1`] = `
`; + +exports[`should change avatar size when using avatar-size prop: 20rem 1`] = `"20rem"`; + +exports[`should change avatar size when using avatar-size prop: 20ren 1`] = `"20rem"`; + +exports[`should render default slot when loading is false 1`] = `
Content
`; + +exports[`should render with row width array correctly 1`] = ` +
+ +
+ +
+
+
+
+
+
+`; diff --git a/src/skeleton/test/index.legacy.js b/src/skeleton/test/index.legacy.js deleted file mode 100644 index be913c433..000000000 --- a/src/skeleton/test/index.legacy.js +++ /dev/null @@ -1,56 +0,0 @@ -import { mount } from '@vue/test-utils'; -import Skeleton from '..'; - -test('row-width array', () => { - const wrapper = mount(Skeleton, { - props: { - row: 4, - rowWidth: ['100%', 30, '5rem'], - }, - }); - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('render chidren', () => { - const wrapper = mount({ - template: ` - -
Content
-
- `, - components: { Skeleton }, - }); - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('avatar shape', () => { - const wrapper = mount(Skeleton, { - props: { - avatar: true, - avatarSize: 20, - avatarShape: 'square', - }, - }); - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('round prop', () => { - const wrapper = mount(Skeleton, { - props: { - title: true, - round: true, - avatar: true, - }, - }); - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('disable animate', () => { - const wrapper = mount(Skeleton, { - props: { - row: 1, - aniamte: false, - }, - }); - expect(wrapper.html()).toMatchSnapshot(); -}); diff --git a/src/skeleton/test/index.spec.js b/src/skeleton/test/index.spec.js new file mode 100644 index 000000000..9c2f1ba15 --- /dev/null +++ b/src/skeleton/test/index.spec.js @@ -0,0 +1,70 @@ +import { mount } from '@vue/test-utils'; +import Skeleton from '..'; + +test('should render with row width array correctly', () => { + const wrapper = mount(Skeleton, { + props: { + row: 4, + rowWidth: ['100%', 30, '5rem'], + }, + }); + expect(wrapper.html()).toMatchSnapshot(); +}); + +test('should render default slot when loading is false', () => { + const wrapper = mount({ + render: () => ( + +
Content
+
+ ), + }); + expect(wrapper.html()).toMatchSnapshot(); +}); + +test('should change avatar size when using avatar-size prop', () => { + const wrapper = mount(Skeleton, { + props: { + avatar: true, + avatarSize: '20rem', + }, + }); + + const avatar = wrapper.find('.van-skeleton__avatar').element; + expect(avatar.style.width).toMatchSnapshot('20rem'); + expect(avatar.style.height).toMatchSnapshot('20ren'); +}); + +test('should change avatar shape when using avatar-shape prop', () => { + const wrapper = mount(Skeleton, { + props: { + avatar: true, + avatarShape: 'square', + }, + }); + expect(wrapper.find('.van-skeleton__avatar').html()).toMatchSnapshot(); +}); + +test('should be round when using round prop', () => { + const wrapper = mount(Skeleton, { + props: { + title: true, + round: true, + avatar: true, + }, + }); + expect(wrapper.find('.van-skeleton--round').exists()).toBeTruthy(); +}); + +test('should allow to disable animation', async () => { + const wrapper = mount(Skeleton, { + props: { + row: 1, + }, + }); + + expect(wrapper.find('.van-skeleton--animate').exists()).toBeTruthy(); + + await wrapper.setProps({ animate: false }); + expect(wrapper.find('.van-skeleton--animate').exists()).toBeFalsy(); +});