fix(Tab): can't match when name is 0 (#5017)

This commit is contained in:
neverland
2019-11-14 20:10:22 +08:00
committed by GitHub
parent 5d157c409b
commit d068286562
2 changed files with 22 additions and 3 deletions
+20 -1
View File
@@ -173,7 +173,6 @@ test('click event', async () => {
expect(onDisabled).toHaveBeenCalledWith(1, 'title2');
});
test('name prop', async () => {
const onClick = jest.fn();
const onChange = jest.fn();
@@ -208,3 +207,23 @@ test('name prop', async () => {
expect(onDisabled).toHaveBeenCalledWith('c', 'title3');
expect(onChange).toHaveBeenCalledTimes(1);
});
test('set name to zero', async () => {
const onClick = jest.fn();
const wrapper = mount({
template: `
<van-tabs @click="onClick">
<van-tab title="title1" :name="1">Text</van-tab>
<van-tab title="title2" :name="0">Text</van-tab>
</van-tabs>
`,
methods: {
onClick
}
});
const tabs = wrapper.findAll('.van-tab');
tabs.at(1).trigger('click');
expect(onClick).toHaveBeenCalledWith(0, 'title2');
});