mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-05 05:42:44 +08:00
47 lines
864 B
JavaScript
47 lines
864 B
JavaScript
import { mount } from '../../../test/utils';
|
|
import AddressList from '..';
|
|
|
|
const list = [
|
|
{
|
|
id: '1',
|
|
name: '张三',
|
|
tel: '13000000000',
|
|
address: '浙江省杭州市西湖区文三路 138 号东方通信大厦 7 楼 501 室'
|
|
},
|
|
{
|
|
id: '2',
|
|
name: '李四',
|
|
tel: '1310000000',
|
|
address: '浙江省杭州市拱墅区莫干山路 50 号'
|
|
}
|
|
];
|
|
|
|
test('unswitchable', () => {
|
|
const wrapper = mount(AddressList, {
|
|
propsData: {
|
|
list,
|
|
switchable: false
|
|
}
|
|
});
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
test('select event', () => {
|
|
const onSelect = jest.fn();
|
|
const wrapper = mount(AddressList, {
|
|
propsData: {
|
|
list
|
|
},
|
|
context: {
|
|
on: {
|
|
select: onSelect
|
|
}
|
|
}
|
|
});
|
|
|
|
wrapper.find('.van-radio__icon').trigger('click');
|
|
|
|
expect(onSelect).toHaveBeenCalledTimes(1);
|
|
});
|