mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[improvement] Switch: add test case
This commit is contained in:
parent
166afd1b04
commit
a13cdcae61
@ -37,3 +37,26 @@ test('disabled', () => {
|
||||
expect(input).toHaveBeenCalledTimes(0);
|
||||
expect(change).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test('active-value & inactive-value prop', () => {
|
||||
const input = jest.fn();
|
||||
const change = jest.fn();
|
||||
const wrapper = mount(Switch, {
|
||||
propsData: {
|
||||
value: '1',
|
||||
activeValue: '1',
|
||||
inactiveValue: '2'
|
||||
},
|
||||
context: {
|
||||
on: {
|
||||
input,
|
||||
change
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.trigger('click');
|
||||
|
||||
expect(input).toHaveBeenCalledWith('2');
|
||||
expect(change).toHaveBeenCalledWith('2');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user