[improvement] CouponCell: functional (#2759)

This commit is contained in:
neverland
2019-02-16 11:39:26 +08:00
committed by GitHub
parent f6ab03fa7e
commit 2ad525c45d
3 changed files with 74 additions and 68 deletions
+15 -9
View File
@@ -109,21 +109,27 @@ test('exchange coupon', () => {
expect(wrapper.emitted('input')[2][0]).toBe('2');
});
test('coupon cell', () => {
test('render coupon cell', () => {
const onClick = jest.fn();
const wrapper = mount(CouponCell, {
listeners: {
click: onClick
context: {
on: {
click: onClick
}
}
});
expect(wrapper).toMatchSnapshot();
wrapper.setProps({
coupons: [{ value: 100 }],
chosenCoupon: 0
});
expect(wrapper).toMatchSnapshot();
wrapper.trigger('click');
expect(onClick.mock.calls.length).toEqual(1);
});
test('render coupon cell with coupon', () => {
const wrapper = mount(CouponCell, {
propsData: {
coupons: [{ value: 100 }],
chosenCoupon: 0
}
});
expect(wrapper).toMatchSnapshot();
});