mirror of
https://github.com/youzan/vant.git
synced 2025-10-20 02:31:21 +00:00
[improvement] rename packages dir to src (#3659)
This commit is contained in:
37
src/tree-select/test/index.spec.js
Normal file
37
src/tree-select/test/index.spec.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import TreeSelect from '..';
|
||||
import { mount } from '../../../test/utils';
|
||||
|
||||
test('empty list', () => {
|
||||
expect(mount(TreeSelect)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('select item', () => {
|
||||
const onItemClick = jest.fn();
|
||||
const item = {
|
||||
text: 'city1',
|
||||
id: 1
|
||||
};
|
||||
|
||||
const wrapper = mount(TreeSelect, {
|
||||
propsData: {
|
||||
items: [{
|
||||
text: 'group1',
|
||||
children: [
|
||||
item,
|
||||
{ ...item, disabled: true }
|
||||
]
|
||||
}]
|
||||
},
|
||||
context: {
|
||||
on: {
|
||||
itemclick: onItemClick
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const items = wrapper.findAll('.van-tree-select__item');
|
||||
items.at(0).trigger('click');
|
||||
expect(onItemClick).toHaveBeenCalledWith(item);
|
||||
items.at(1).trigger('click');
|
||||
expect(onItemClick).toHaveBeenCalledTimes(1);
|
||||
});
|
Reference in New Issue
Block a user