[new feature] Tabs: add animated props to change tabs with animation (#2126)

This commit is contained in:
张敏
2018-11-23 19:51:47 +08:00
committed by neverland
parent 8042e37829
commit d84b13a6cc
15 changed files with 2097 additions and 268 deletions
+37 -3
View File
@@ -5,9 +5,18 @@ import { mount, later, triggerDrag } from '../../../test/utils';
function createWrapper(options) {
return mount({
template: `
<tabs @change="onChange" swipeable>
<tab title="title1">Text</tab>
<tab title="title2">Text</tab>
<tabs @change="onChange"
:color="color"
:type="type"
:swipeable="swipeable"
:sticky="sticky"
:line-width="lineWidth"
>
<tab :title="title1">Text</tab>
<tab>
<span slot="title">title2</span>
Text
</tab>
<tab title="title3" disabled>Text</tab>
</tabs>
`,
@@ -15,6 +24,16 @@ function createWrapper(options) {
Tab,
Tabs
},
data() {
return {
title1: 'title1',
color: '#f44',
type: 'line',
swipeable: true,
sticky: true,
lineWidth: 2
};
},
...options
});
}
@@ -61,3 +80,18 @@ test('swipe to switch tab', async() => {
await later();
wrapper.destroy();
});
test('change tabs data', async() => {
const wrapper = createWrapper();
expect(wrapper).toMatchSnapshot();
wrapper.setData({
swipeable: false,
sticky: false,
type: 'card',
color: 'blue',
title1: 'new title1'
});
expect(wrapper).toMatchSnapshot();
});