[new feature] Rate: add allow-half prop (#3134)

This commit is contained in:
neverland
2019-04-11 17:14:34 +08:00
committed by GitHub
parent e6d4f331a8
commit 9ecbcae725
7 changed files with 314 additions and 74 deletions
+23 -1
View File
@@ -13,13 +13,35 @@ test('change event', () => {
}
}
});
const item4 = wrapper.findAll('.van-rate__item').at(3);
const item4 = wrapper.findAll('.van-rate__icon').at(3);
item4.trigger('click');
expect(onInput).toHaveBeenCalledWith(4);
expect(onChange).toHaveBeenCalledWith(4);
});
test('allow half', () => {
const onInput = jest.fn();
const onChange = jest.fn();
const wrapper = mount(Rate, {
propsData: {
allowHalf: true
},
context: {
on: {
input: onInput,
change: onChange
}
}
});
const item4 = wrapper.findAll('.van-rate__icon--half').at(3);
item4.trigger('click');
expect(onInput).toHaveBeenCalledWith(3.5);
expect(onChange).toHaveBeenCalledWith(3.5);
});
test('disabled', () => {
const onInput = jest.fn();
const onChange = jest.fn();