diff --git a/babel.config.js b/babel.config.js
index 74091d09a..22272e76a 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -16,8 +16,6 @@ module.exports = function (api) {
[
'@vue/babel-preset-jsx',
{
- vModel: true,
- injectH: true,
functional: false
}
]
diff --git a/package.json b/package.json
index 986c9b21d..49bccff07 100644
--- a/package.json
+++ b/package.json
@@ -79,8 +79,8 @@
"@vant/markdown-loader": "^1.0.3",
"@vue/babel-helper-vue-jsx-merge-props": "^1.0.0-beta.1",
"@vue/babel-preset-jsx": "^1.0.0-beta.1",
- "@vue/server-test-utils": "^1.0.0-beta.26",
- "@vue/test-utils": "^1.0.0-beta.26",
+ "@vue/server-test-utils": "^1.0.0-beta.28",
+ "@vue/test-utils": "^1.0.0-beta.28",
"autoprefixer": "^9.4.3",
"babel-core": "^7.0.0-0",
"babel-jest": "^23.6.0",
diff --git a/packages/coupon-list/demo/index.vue b/packages/coupon-list/demo/index.vue
index 268647fe8..7ad933af0 100644
--- a/packages/coupon-list/demo/index.vue
+++ b/packages/coupon-list/demo/index.vue
@@ -30,14 +30,16 @@ export default {
'zh-CN': {
coupon: {
name: '优惠券名称',
- reason: '优惠券不可用原因'
+ reason: '优惠券不可用原因',
+ description: '描述信息'
},
exchange: '兑换成功'
},
'en-US': {
coupon: {
name: 'Coupon name',
- reason: 'Coupon unavailable reason'
+ reason: 'Coupon unavailable reason',
+ description: 'Description'
},
exchange: 'Success'
}
@@ -63,13 +65,13 @@ export default {
coupon() {
return {
id: 1,
- available: 1,
discount: 0,
denominations: 150,
originCondition: 0,
reason: '',
value: 150,
name: this.$t('coupon.name'),
+ description: this.$t('coupon.description'),
startAt: 1489104000,
endAt: 1514592000
};
@@ -90,7 +92,6 @@ export default {
return {
...this.coupon,
id: 3,
- available: 0,
reason: this.$t('coupon.reason')
};
},
@@ -100,7 +101,6 @@ export default {
...this.discountCoupon,
discount: 10,
id: 4,
- available: 0,
reason: this.$t('coupon.reason')
};
}
diff --git a/packages/coupon-list/en-US.md b/packages/coupon-list/en-US.md
index 89e3daaf2..963fec6c8 100644
--- a/packages/coupon-list/en-US.md
+++ b/packages/coupon-list/en-US.md
@@ -111,5 +111,6 @@ export default {
| originCondition | Condition | `Number` |
| startAt | Start time (Timestmap, unit second) | `Number` |
| endAt | End time (Timestmap, unit second) | `Number` |
+| description | Description | `String` |
| reason | Unavailable reason | `String` |
| value | Value | `Number` |
diff --git a/packages/coupon-list/test/__snapshots__/index.spec.js.snap b/packages/coupon-list/test/__snapshots__/index.spec.js.snap
index 7d6a962cf..191c818d1 100644
--- a/packages/coupon-list/test/__snapshots__/index.spec.js.snap
+++ b/packages/coupon-list/test/__snapshots__/index.spec.js.snap
@@ -23,3 +23,139 @@ exports[`coupon cell 2`] = `
`;
+
+exports[`render coupon list 1`] = `
+
+
+
+
+
+
+
可使用优惠券 (6)
+
不可使用优惠券 (2)
+
+
+
+
+
+
+
+
+
+
+
有效期:2017.03.10 - 2017.12.30
+
+
+
+
+
+
+
+
name
+
有效期:2017.03.10 - 2017.12.30
+
+
+
+
description
+
+
+
+
+
+
name
+
有效期:2017.03.10 - 2017.12.30
+
+
+
description
+
+
+
+
+
+
name
+
有效期:2017.03.10 - 2017.12.30
+
+
+
description
+
+
+
+
+
+
name
+
有效期:2017.03.10 - 2017.12.30
+
+
+
+
+
+
+
+
name
+
有效期:2017.03.10 - 2017.12.30
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`render disabled coupon 1`] = `
+
+
+
+
+
name
+
有效期:2017.03.10 - 2017.12.30
+
+
+
reason
+
+`;
diff --git a/packages/coupon-list/test/index.spec.js b/packages/coupon-list/test/index.spec.js
index 4a8792862..dc8e51713 100644
--- a/packages/coupon-list/test/index.spec.js
+++ b/packages/coupon-list/test/index.spec.js
@@ -1,6 +1,94 @@
+import Coupon from '../../coupon';
import CouponList from '..';
import CouponCell from '../../coupon-cell';
-import { mount } from '../../../test/utils';
+import { later, mount } from '../../../test/utils';
+
+const coupon = {
+ id: 1,
+ discount: 0,
+ denominations: 150,
+ originCondition: 0,
+ reason: '',
+ value: 150,
+ name: 'name',
+ description: 'description',
+ startAt: 1489104000,
+ endAt: 1514592000
+};
+
+const coupon2 = {
+ ...coupon,
+ denominations: 100
+};
+
+const coupon3 = {
+ ...coupon,
+ denominations: 123
+};
+
+const emptyCoupon = {
+ id: 0,
+ discount: 0,
+ denominations: 0,
+ originCondition: 0,
+ startAt: 1489104000,
+ endAt: 1514592000
+};
+
+const discountCoupon = {
+ ...coupon,
+ id: 2,
+ discount: 88,
+ denominations: 0,
+ originCondition: 50,
+ value: 12,
+ description: ''
+};
+
+const discountCoupon2 = {
+ ...coupon,
+ id: 2,
+ discount: 90,
+ denominations: 0,
+ originCondition: 50,
+ value: 12,
+ description: ''
+};
+
+const disabledCoupon = {
+ ...coupon,
+ id: 3,
+ reason: 'reason'
+};
+
+const disabledDiscountCoupon = {
+ ...discountCoupon,
+ discount: 10,
+ id: 4,
+ reason: ''
+};
+
+test('render disabled coupon', () => {
+ const wrapper = mount(Coupon, {
+ propsData: {
+ coupon: disabledCoupon,
+ disabled: true
+ }
+ });
+ expect(wrapper).toMatchSnapshot();
+});
+
+test('render coupon list', async () => {
+ const wrapper = mount(CouponList, {
+ propsData: {
+ chosenCoupon: 1,
+ coupons: [emptyCoupon, coupon, coupon2, coupon3, discountCoupon, discountCoupon2],
+ disabledCoupons: [disabledCoupon, disabledDiscountCoupon]
+ }
+ });
+ await later();
+ expect(wrapper).toMatchSnapshot();
+});
test('exchange coupon', () => {
const wrapper = mount(CouponList);
@@ -22,7 +110,12 @@ test('exchange coupon', () => {
});
test('coupon cell', () => {
- const wrapper = mount(CouponCell);
+ const onClick = jest.fn();
+ const wrapper = mount(CouponCell, {
+ listeners: {
+ click: onClick
+ }
+ });
expect(wrapper).toMatchSnapshot();
wrapper.setProps({
@@ -30,4 +123,7 @@ test('coupon cell', () => {
chosenCoupon: 0
});
expect(wrapper).toMatchSnapshot();
+
+ wrapper.trigger('click');
+ expect(onClick.mock.calls.length).toEqual(1);
});
diff --git a/packages/coupon-list/zh-CN.md b/packages/coupon-list/zh-CN.md
index f92005ee0..0d75f96c5 100644
--- a/packages/coupon-list/zh-CN.md
+++ b/packages/coupon-list/zh-CN.md
@@ -116,5 +116,6 @@ export default {
| originCondition | 满减条件(0为无门槛,满XX元可用)单位分 | `Number` |
| startAt | 卡有效开始时间 (时间戳, 单位秒) | `Number` |
| endAt | 卡失效日期 (时间戳, 单位秒) | `Number` |
-| reason | 不可用原因 | `String` |
+| description | 描述信息,优惠券可用时展示 | `String` |
+| reason | 不可用原因,优惠券不可用时展示 | `String` |
| value | 折扣券优惠金额,单位分 | `Number` |
diff --git a/packages/coupon/index.js b/packages/coupon/index.js
index 59a1f73ea..e61e8ae03 100644
--- a/packages/coupon/index.js
+++ b/packages/coupon/index.js
@@ -53,9 +53,10 @@ export default sfc({
render(h) {
const { coupon, disabled } = this;
+ const description = (disabled && coupon.reason) || coupon.description;
return (
-
+
@@ -67,7 +68,7 @@ export default sfc({
{this.chosen && }
- {(disabled && coupon.reason) &&
{coupon.reason}
}
+ {description &&
{description}
}
);
}
diff --git a/packages/coupon/index.less b/packages/coupon/index.less
index 216e1f458..55b2f79e9 100644
--- a/packages/coupon/index.less
+++ b/packages/coupon/index.less
@@ -72,7 +72,7 @@
}
}
- &__reason {
+ &__description {
padding: 7px 15px;
border-top: 1px dashed @border-color;
background-color: @background-color-light;
diff --git a/yarn.lock b/yarn.lock
index 56c68478b..5ce0cf4ae 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -802,15 +802,17 @@
source-map "^0.5.6"
vue-template-es2015-compiler "^1.6.0"
-"@vue/server-test-utils@^1.0.0-beta.26":
- version "1.0.0-beta.27"
- resolved "https://registry.yarnpkg.com/@vue/server-test-utils/-/server-test-utils-1.0.0-beta.27.tgz#0c61cb724d04bf44c70938b4a6054e73e914492a"
+"@vue/server-test-utils@^1.0.0-beta.28":
+ version "1.0.0-beta.28"
+ resolved "https://registry.yarnpkg.com/@vue/server-test-utils/-/server-test-utils-1.0.0-beta.28.tgz#40adb6a6c05e8970cc5e5f0869eb490fa00d9cf3"
+ integrity sha512-CrXQ2ISmLvye4HC4sIHqqR3Gyg02i8XcTwMAyIh+UY7fh1Nz4f9XE4LDsxg0B9uSGsSiR0lwphjlGtbUJjGl4A==
dependencies:
cheerio "^1.0.0-rc.2"
-"@vue/test-utils@^1.0.0-beta.26":
- version "1.0.0-beta.27"
- resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.27.tgz#7e5f7b7180c00e28a4ca55c0ff0a7e754377fdb2"
+"@vue/test-utils@^1.0.0-beta.28":
+ version "1.0.0-beta.28"
+ resolved "https://registry.yarnpkg.com/@vue/test-utils/-/test-utils-1.0.0-beta.28.tgz#767c43413df8cde86128735e58923803e444b9a5"
+ integrity sha512-uVbFJG0g/H9hf2pgWUdhvQYItRGzQ44cMFf00wp0YEo85pxuvM9e3mx8QLQfx6R2CogxbK4CvV7qvkLblehXeQ==
dependencies:
dom-event-types "^1.0.0"
lodash "^4.17.4"