diff --git a/src/overlay/test/__snapshots__/index.legacy.js.snap b/src/overlay/test/__snapshots__/index.legacy.js.snap
deleted file mode 100644
index 07b7885df..000000000
--- a/src/overlay/test/__snapshots__/index.legacy.js.snap
+++ /dev/null
@@ -1,11 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`class-name prop 1`] = `
`;
-
-exports[`custom style prop 1`] = ``;
-
-exports[`default slot 1`] = `Custom Default
`;
-
-exports[`duration prop 1`] = ``;
-
-exports[`z-index prop 1`] = ``;
diff --git a/src/overlay/test/__snapshots__/index.spec.js.snap b/src/overlay/test/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..3106b93fc
--- /dev/null
+++ b/src/overlay/test/__snapshots__/index.spec.js.snap
@@ -0,0 +1,6 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render default slot correctly 1`] = `
+
+
+`;
diff --git a/src/overlay/test/index.legacy.js b/src/overlay/test/index.legacy.js
deleted file mode 100644
index bade1a42a..000000000
--- a/src/overlay/test/index.legacy.js
+++ /dev/null
@@ -1,98 +0,0 @@
-import { mount } from '@vue/test-utils';
-import Overlay from '..';
-
-test('z-index prop', () => {
- const wrapper = mount(Overlay, {
- props: {
- show: true,
- zIndex: 99,
- },
- });
-
- expect(wrapper.html()).toMatchSnapshot();
-});
-
-test('class-name prop', () => {
- const wrapper = mount(Overlay, {
- props: {
- show: true,
- className: 'my-overlay',
- },
- });
-
- expect(wrapper.html()).toMatchSnapshot();
-});
-
-test('custom style prop', () => {
- const wrapper = mount(Overlay, {
- props: {
- show: true,
- customStyle: {
- backgroundColor: 'red',
- },
- },
- });
-
- expect(wrapper.html()).toMatchSnapshot();
-});
-
-test('duration prop', () => {
- const wrapper = mount(Overlay, {
- props: {
- show: true,
- duration: 1,
- },
- });
-
- expect(wrapper.html()).toMatchSnapshot();
-});
-
-test('click event', () => {
- const onClick = jest.fn();
- const wrapper = mount(Overlay, {
- context: {
- on: {
- click: onClick,
- },
- },
- });
-
- wrapper.trigger('click');
- expect(onClick).toHaveBeenCalledTimes(1);
-});
-
-test('default slot', () => {
- const wrapper = mount(Overlay, {
- slots: {
- default: () => 'Custom Default',
- },
- });
-
- expect(wrapper.html()).toMatchSnapshot();
-});
-
-test('lock-scroll prop', () => {
- const onTouchMove = jest.fn();
- const wrapper = mount({
- template: `
-
-
-
- `,
- data() {
- return {
- lockScroll: true,
- };
- },
- methods: {
- onTouchMove,
- },
- });
-
- wrapper.find('.van-overlay').trigger('touchmove');
- expect(onTouchMove).toHaveBeenCalledTimes(0);
-
- wrapper.setData({ lockScroll: false });
- wrapper.find('.van-overlay').trigger('touchmove');
- expect(onTouchMove).toHaveBeenCalledTimes(1);
-});
diff --git a/src/overlay/test/index.spec.js b/src/overlay/test/index.spec.js
new file mode 100644
index 000000000..6138ffdfe
--- /dev/null
+++ b/src/overlay/test/index.spec.js
@@ -0,0 +1,96 @@
+import { mount } from '@vue/test-utils';
+import Overlay from '..';
+
+test('should change z-index when using z-index prop', () => {
+ const wrapper = mount(Overlay, {
+ props: {
+ show: true,
+ zIndex: 99,
+ },
+ });
+
+ const overlay = wrapper.find('.van-overlay').element;
+ expect(overlay.style.zIndex).toEqual('99');
+});
+
+test('should allow to custom class name with class-name prop', () => {
+ const wrapper = mount(Overlay, {
+ props: {
+ show: true,
+ className: 'foo',
+ },
+ });
+
+ const overlay = wrapper.find('.van-overlay').element;
+ expect(overlay.classList.contains('foo')).toBeTruthy();
+});
+
+test('should allow to custom style with custom-style prop', () => {
+ const wrapper = mount(Overlay, {
+ props: {
+ show: true,
+ customStyle: {
+ backgroundColor: 'red',
+ },
+ },
+ });
+
+ const overlay = wrapper.find('.van-overlay').element;
+ expect(overlay.style.backgroundColor).toEqual('red');
+});
+
+test('should change animation duration when using duration prop', () => {
+ const wrapper = mount(Overlay, {
+ props: {
+ show: true,
+ duration: 1,
+ },
+ });
+
+ const overlay = wrapper.find('.van-overlay').element;
+ expect(overlay.style.animationDuration).toEqual('1s');
+});
+
+test('should render default slot correctly', () => {
+ const wrapper = mount(Overlay, {
+ slots: {
+ default: () => 'Custom Default',
+ },
+ });
+
+ expect(wrapper.html()).toMatchSnapshot();
+});
+
+test('should allow to touchmove when lock-scroll is false', async () => {
+ const onTouchMove = jest.fn();
+ const wrapper = mount({
+ render() {
+ return (
+
+
+
+ );
+ },
+ });
+
+ const overlay = wrapper.find('.van-overlay');
+ overlay.trigger('touchmove');
+ expect(onTouchMove).toHaveBeenCalledTimes(1);
+});
+
+test('should not allow to touchmove when lock-scroll is true', async () => {
+ const onTouchMove = jest.fn();
+ const wrapper = mount({
+ render() {
+ return (
+
+
+
+ );
+ },
+ });
+
+ const overlay = wrapper.find('.van-overlay');
+ overlay.trigger('touchmove');
+ expect(onTouchMove).toHaveBeenCalledTimes(0);
+});