[improvement] Card: add click event params (#3780)

This commit is contained in:
neverland
2019-07-08 17:02:12 +08:00
committed by GitHub
parent abc555dd72
commit 701446ece8
4 changed files with 48 additions and 7 deletions
+41
View File
@@ -1,6 +1,47 @@
import Card from '..';
import { mount } from '../../../test/utils';
test('click event', () => {
const onClick = jest.fn();
const wrapper = mount(Card, {
context: {
on: {
click: onClick
}
}
});
wrapper.trigger('click');
expect(onClick).toHaveBeenCalledWith(
expect.objectContaining({
isTrusted: expect.any(Boolean)
})
);
});
test('click-thumb event', () => {
const onClickThumb = jest.fn();
const wrapper = mount(Card, {
propsData: {
thumb: 'xx'
},
context: {
on: {
'click-thumb': onClickThumb
}
}
});
wrapper.find('.van-card__thumb').trigger('click');
expect(onClickThumb).toHaveBeenCalledWith(
expect.objectContaining({
isTrusted: expect.any(Boolean)
})
);
});
test('render price & num slot', () => {
const wrapper = mount(Card, {
scopedSlots: {