[improvement] optimize jest fn called judgement (#3029)

This commit is contained in:
neverland
2019-03-21 18:57:44 +08:00
committed by GitHub
parent 7c4908a2e3
commit 8c051b8e1f
24 changed files with 63 additions and 64 deletions
+7 -5
View File
@@ -16,8 +16,8 @@ test('change event', () => {
const item4 = wrapper.findAll('.van-rate__item').at(3);
item4.trigger('click');
expect(onInput.mock.calls[0][0]).toEqual(4);
expect(onChange.mock.calls[0][0]).toEqual(4);
expect(onInput).toHaveBeenCalledWith(4);
expect(onChange).toHaveBeenCalledWith(4);
});
test('disabled', () => {
@@ -38,8 +38,8 @@ test('disabled', () => {
const item4 = wrapper.findAll('.van-rate__item').at(3);
item4.trigger('click');
expect(onInput.mock.calls.length).toEqual(0);
expect(onChange.mock.calls.length).toEqual(0);
expect(onInput).toHaveBeenCalledTimes(0);
expect(onChange).toHaveBeenCalledTimes(0);
});
test('touchmove', () => {
@@ -62,5 +62,7 @@ test('touchmove', () => {
};
triggerDrag(wrapper, 100, 0);
expect(onChange.mock.calls).toEqual([[2], [3], [4]]);
expect(onChange).toHaveBeenNthCalledWith(1, 2);
expect(onChange).toHaveBeenNthCalledWith(2, 3);
expect(onChange).toHaveBeenNthCalledWith(3, 4);
});