[new feature] Tab: add name prop (#3762)

This commit is contained in:
neverland
2019-07-05 14:14:20 +08:00
committed by GitHub
parent 2389ac06ba
commit b802047e24
12 changed files with 243 additions and 84 deletions
+35
View File
@@ -145,3 +145,38 @@ test('border props', async () => {
expect(wrapper).toMatchSnapshot();
});
test('name prop', async () => {
const onClick = jest.fn();
const onChange = jest.fn();
const onDisabled = jest.fn();
const wrapper = mount({
template: `
<van-tabs @click="onClick" @disabled="onDisabled" @change="onChange">
<van-tab title="title1" name="a">Text</van-tab>
<van-tab title="title2" name="b">Text</van-tab>
<van-tab title="title3" name="c" disabled>Text</van-tab>
</van-tabs>
`,
methods: {
onClick,
onChange,
onDisabled
}
});
await later();
expect(wrapper).toMatchSnapshot();
const tabs = wrapper.findAll('.van-tab');
tabs.at(1).trigger('click');
expect(onClick).toHaveBeenCalledWith('b', 'title2');
expect(onChange).toHaveBeenCalledWith('b', 'title2');
expect(onChange).toHaveBeenCalledTimes(1);
tabs.at(2).trigger('click');
expect(onDisabled).toHaveBeenCalledWith('c', 'title3');
expect(onChange).toHaveBeenCalledTimes(1);
});