[new feature] Tabs: support switch tabs with swipe gestrue in the content (#694)

This commit is contained in:
张敏
2018-03-15 10:17:51 +08:00
committed by neverland
parent f13a0779fd
commit 5cdf3b1d79
8 changed files with 137 additions and 8 deletions
+32 -1
View File
@@ -2,6 +2,7 @@ import Tabs from 'packages/tabs';
import { mount } from 'avoriaz';
import TabsTestComponent from '../components/tabs';
import MoreTabsTestComponent from '../components/more-tabs';
import { triggerTouch } from '../utils';
describe('Tabs', () => {
let wrapper;
@@ -114,7 +115,7 @@ describe('Tabs', () => {
});
});
it('sticky', (done) => {
it('create a sticky tabs', (done) => {
wrapper = mount(TabsTestComponent, {
attachToDocument: true,
propsData: {
@@ -129,4 +130,34 @@ describe('Tabs', () => {
done();
}, 30);
});
it('create a swipeable tabs', (done) => {
wrapper = mount(TabsTestComponent, {
attachToDocument: true,
propsData: {
swipeable: true
}
});
const tabsContainer = wrapper.find('.van-tabs')[0];
const tabContent = wrapper.find('.van-tabs__content')[0];
expect(tabsContainer.vNode.child.curActive).to.equal(0);
wrapper.vm.$nextTick(() => {
triggerTouch(tabContent, 'touchstart', 0, 0);
triggerTouch(tabContent, 'touchmove', -100, 0);
setTimeout(() => {
expect(tabsContainer.vNode.child.curActive).to.equal(1);
triggerTouch(tabContent, 'touchstart', 0, 0);
triggerTouch(tabContent, 'touchmove', 100, 0);
setTimeout(() => {
expect(tabsContainer.vNode.child.curActive).to.equal(0);
done();
}, 500);
}, 500);
})
});
});