fix(TreeSelect): should sync value before trigger click-item event (#5153)

This commit is contained in:
neverland
2019-11-30 08:22:17 +08:00
committed by GitHub
parent 3c45cdb231
commit d1a8adab20
2 changed files with 36 additions and 4 deletions
+34
View File
@@ -295,3 +295,37 @@ test('className of nav', () => {
const items = wrapper.findAll('.van-tree-select__nav-item');
expect(items.at(0).element.classList.contains('my-class')).toBeTruthy();
});
test('should sync value before trigger click-item event', done => {
const wrapper = mount({
template: `
<van-tree-select
:items="items"
:main-active-index="0"
:active-id.sync="activeId"
@click-item="onClickItem"
/>
`,
data() {
return {
activeId: mockItem.id,
mainActiveIndex: 0,
items: [
{
text: 'group1',
children: [mockItem, mockItem2]
}
]
};
},
methods: {
onClickItem() {
expect(wrapper.vm.activeId).toEqual(mockItem2.id);
done();
}
}
});
const items = wrapper.findAll('.van-tree-select__item');
items.at(1).trigger('click');
});