diff --git a/packages/tab/test/__snapshots__/index.spec.js.snap b/packages/tab/test/__snapshots__/index.spec.js.snap
new file mode 100644
index 000000000..e895ffe91
--- /dev/null
+++ b/packages/tab/test/__snapshots__/index.spec.js.snap
@@ -0,0 +1,153 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`click to switch tab 1`] = `
+
+
+
+
+
title1
+
title2
+
title3
+
+
+
+
Text
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`click to switch tab 2`] = `
+
+
+
+
+
title1
+
title2
+
title3
+
+
+
+
Text
+
+
+
Text
+
+
+
+
+
+
+
+
+`;
+
+exports[`swipe to switch tab 1`] = `
+
+
+
+
+
title1
+
title2
+
title3
+
+
+
+
Text
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`swipe to switch tab 2`] = `
+
+
+
+
+
title1
+
title2
+
title3
+
+
+
+
Text
+
+
+
Text
+
+
+
+
+
+
+
+
+`;
+
+exports[`swipe to switch tab 3`] = `
+
+
+
+
+
title1
+
title2
+
title3
+
+
+
+
Text
+
+
+
Text
+
+
+
+
+
+
+
+
+`;
+
+exports[`swipe to switch tab 4`] = `
+
+
+
+
+
title1
+
title2
+
title3
+
+
+
+
Text
+
+
+
Text
+
+
+
+
+
+
+
+
+`;
diff --git a/packages/tab/test/index.spec.js b/packages/tab/test/index.spec.js
new file mode 100644
index 000000000..f6bb435d6
--- /dev/null
+++ b/packages/tab/test/index.spec.js
@@ -0,0 +1,63 @@
+import Tab from '..';
+import Tabs from '../../tabs';
+import { mount, later, triggerDrag } from '../../../test/utils';
+
+function createWrapper(options) {
+ return mount({
+ template: `
+
+ Text
+ Text
+ Text
+
+ `,
+ components: {
+ Tab,
+ Tabs
+ },
+ ...options
+ });
+}
+
+test('click to switch tab', async() => {
+ const onChange = jest.fn();
+ const wrapper = createWrapper({
+ methods: {
+ onChange
+ }
+ });
+
+ await later();
+ expect(wrapper).toMatchSnapshot();
+
+ const tabs = wrapper.findAll('.van-tab');
+ tabs.at(1).trigger('click');
+ tabs.at(2).trigger('click');
+ await later();
+ expect(wrapper).toMatchSnapshot();
+ expect(onChange.mock.calls.length).toEqual(1);
+});
+
+test('swipe to switch tab', async() => {
+ const onChange = jest.fn();
+ const wrapper = createWrapper({
+ methods: {
+ onChange
+ }
+ });
+
+ const content = wrapper.find('.van-tabs__content');
+ await later();
+ expect(wrapper).toMatchSnapshot();
+ triggerDrag(content, -100, 0);
+ expect(wrapper).toMatchSnapshot();
+ expect(onChange.mock.calls.length).toEqual(1);
+ triggerDrag(content, -100, 0);
+ expect(wrapper).toMatchSnapshot();
+ triggerDrag(content, 100, 0);
+ triggerDrag(content, 100, 0);
+ expect(wrapper).toMatchSnapshot();
+
+ await later();
+ wrapper.destroy();
+});
diff --git a/packages/tabs/index.vue b/packages/tabs/index.vue
index 2134ad1ff..40c42a604 100644
--- a/packages/tabs/index.vue
+++ b/packages/tabs/index.vue
@@ -298,8 +298,6 @@ export default create({
}
index += diff;
}
-
- return active;
},
// emit event when clicked