mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
35 lines
995 B
JavaScript
35 lines
995 B
JavaScript
import demoTest from '../../../test/demo-test';
|
|
import CouponList from '../../coupon-list';
|
|
import CouponCell from '../../coupon-cell';
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
demoTest(CouponList);
|
|
|
|
test('exchange coupon', () => {
|
|
const wrapper = mount(CouponList);
|
|
const exchange = wrapper.find('.van-coupon-list__exchange');
|
|
|
|
wrapper.vm.displayedCouponIndex = 1;
|
|
wrapper.vm.currentCode = '1';
|
|
exchange.trigger('click');
|
|
wrapper.vm.code = '2';
|
|
exchange.trigger('click');
|
|
|
|
expect(wrapper.emitted('exchange')[0][0]).toBe('1');
|
|
expect(wrapper.emitted('exchange')[1][0]).toBe('2');
|
|
expect(wrapper.emitted('input')[0][0]).toBe('1');
|
|
expect(wrapper.emitted('input')[1][0]).toBe('');
|
|
expect(wrapper.emitted('input')[2][0]).toBe('2');
|
|
});
|
|
|
|
test('coupon cell', () => {
|
|
const wrapper = mount(CouponCell);
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
wrapper.setProps({
|
|
coupons: [{ value: 100 }],
|
|
chosenCoupon: 0
|
|
});
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
});
|