mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 09:24:25 +00:00
fix(CouponCell): discounted value (#7196)
* fix(CouponCell): discounted value * feat(CouponCell): add unit test * feat(CouponCell): add unit test
This commit is contained in:
@@ -30,9 +30,7 @@ function formatValue(props: CouponCellProps) {
|
|||||||
|
|
||||||
if (isDef(coupon.value)) {
|
if (isDef(coupon.value)) {
|
||||||
({ value } = coupon);
|
({ value } = coupon);
|
||||||
}
|
} else if (isDef(coupon.denominations)) {
|
||||||
|
|
||||||
if (isDef(coupon.denominations)) {
|
|
||||||
value = coupon.denominations;
|
value = coupon.denominations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,6 +54,15 @@ exports[`render coupon cell with coupon 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
|
||||||
|
exports[`render coupon cell with zero discount 1`] = `
|
||||||
|
<div role="button" tabindex="0" class="van-cell van-cell--clickable van-coupon-cell">
|
||||||
|
<div class="van-cell__title"><span>优惠券</span></div>
|
||||||
|
<div class="van-cell__value van-coupon-cell__value van-coupon-cell__value--selected"><span>-¥ 0.00</span></div><i class="van-icon van-icon-arrow van-cell__right-icon">
|
||||||
|
<!----></i>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`render coupon list 1`] = `
|
exports[`render coupon list 1`] = `
|
||||||
<div class="van-coupon-list">
|
<div class="van-coupon-list">
|
||||||
<div class="van-coupon-list__exchange-bar">
|
<div class="van-coupon-list__exchange-bar">
|
||||||
|
@@ -26,6 +26,12 @@ const coupon3 = {
|
|||||||
denominations: 123,
|
denominations: 123,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const coupon4 = {
|
||||||
|
...coupon,
|
||||||
|
startAt: 1600327871,
|
||||||
|
endAt: 1700327871,
|
||||||
|
};
|
||||||
|
|
||||||
const emptyCoupon = {
|
const emptyCoupon = {
|
||||||
id: 0,
|
id: 0,
|
||||||
discount: 0,
|
discount: 0,
|
||||||
@@ -162,3 +168,13 @@ test('render coupon cell with coupon', () => {
|
|||||||
});
|
});
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('render coupon cell with zero discount', () => {
|
||||||
|
const wrapper = mount(CouponCell, {
|
||||||
|
propsData: {
|
||||||
|
coupons: [{ ...coupon4, value: 0, denominations: 150 }],
|
||||||
|
chosenCoupon: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
Reference in New Issue
Block a user