diff --git a/src/tab/test/__snapshots__/insert.legacy.js.snap b/src/tab/test/__snapshots__/insert.legacy.js.snap deleted file mode 100644 index bd82b97fe..000000000 --- a/src/tab/test/__snapshots__/insert.legacy.js.snap +++ /dev/null @@ -1,63 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`insert tab dynamically 1`] = ` -
-
-
- - - -
-
-
-
- -
-
2
-
- -
-
-`; - -exports[`insert tab with child component 1`] = ` -
-
-
- - - -
-
-
-
-
1
- - -
-
-`; - -exports[`insert tab with name dynamically 1`] = ` -
-
-
- - -
-
-
-
- -
1
-
-
-`; diff --git a/src/tab/test/__snapshots__/insert.spec.js.snap b/src/tab/test/__snapshots__/insert.spec.js.snap new file mode 100644 index 000000000..1fe777803 --- /dev/null +++ b/src/tab/test/__snapshots__/insert.spec.js.snap @@ -0,0 +1,162 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render Tab inside a component correctly 1`] = ` +
+
+
+ + + +
+
+
+
+
+
+ 1 +
+ + +
+
+`; + +exports[`should render correctly after inserting a tab 1`] = ` +
+
+
+ + + +
+
+
+
+
+ +
+
+ 2 +
+
+ +
+
+`; + +exports[`should render correctly after inserting a tab with name 1`] = ` +
+
+
+ + +
+
+
+
+
+ +
+ foo +
+
+
+`; diff --git a/src/tab/test/insert.legacy.js b/src/tab/test/insert.legacy.js deleted file mode 100644 index 9ac0e07e3..000000000 --- a/src/tab/test/insert.legacy.js +++ /dev/null @@ -1,75 +0,0 @@ -import { mount, later } from '../../../test'; - -// this case will throw wierd error in index.spec.js -// so separate it -test('insert tab dynamically', async () => { - const wrapper = mount({ - template: ` - - 1 -
- 2 -
- 3 -
- `, - data() { - return { - insert: false, - active: 1, - }; - }, - }); - - await later(); - wrapper.setData({ insert: true }); - expect(wrapper.html()).toMatchSnapshot(); -}); - -test('insert tab with name dynamically', async () => { - const onChange = jest.fn(); - const wrapper = mount({ - template: ` - - 2 - 1 - - `, - data() { - return { - insert: false, - active: 'foo', - }; - }, - methods: { - onChange, - }, - }); - - await later(); - wrapper.setData({ insert: true }); - expect(wrapper.html()).toMatchSnapshot(); - expect(onChange).toHaveBeenCalledTimes(0); -}); - -// this case will throw wierd error in index.spec.js -// so separate it -test('insert tab with child component', async () => { - const wrapper = mount({ - template: ` - - 1 - - 3 - - `, - components: { - 'my-tab': { - template: `2`, - }, - }, - }); - - await later(); - expect(wrapper.html()).toMatchSnapshot(); -}); diff --git a/src/tab/test/insert.spec.js b/src/tab/test/insert.spec.js new file mode 100644 index 000000000..0254a37aa --- /dev/null +++ b/src/tab/test/insert.spec.js @@ -0,0 +1,85 @@ +import { mount, later } from '../../../test'; +import Tab from '..'; +import Tabs from '../../tabs'; + +test('should render correctly after inserting a tab', async () => { + const wrapper = mount({ + render() { + return ( + + 1 + {this.insert && ( +
+ 2 +
+ )} + 3 +
+ ); + }, + data() { + return { + insert: false, + active: 1, + }; + }, + }); + + await later(); + await wrapper.setData({ insert: true }); + expect(wrapper.html()).toMatchSnapshot(); +}); + +test('should render correctly after inserting a tab with name', async () => { + const onChange = jest.fn(); + const wrapper = mount({ + render() { + return ( + + {this.insert && ( + + bar + + )} + + foo + + + ); + }, + data() { + return { + insert: false, + active: 'foo', + }; + }, + }); + + await later(); + await wrapper.setData({ insert: true }); + expect(wrapper.html()).toMatchSnapshot(); + expect(onChange).toHaveBeenCalledTimes(0); +}); + +test('should render Tab inside a component correctly', async () => { + const MyTab = { + render() { + return 2; + }, + }; + + const wrapper = mount({ + render() { + return ( + + 1 + + 3 + + ); + }, + }); + + await later(); + expect(wrapper.html()).toMatchSnapshot(); +});