OrderGoods: fix message test cases

This commit is contained in:
陈嘉涵 2017-08-31 15:53:11 +08:00
parent 3de9f86b47
commit 13a41e0e1e
5 changed files with 25 additions and 26 deletions

View File

@ -221,6 +221,12 @@ export default {
| is_period_buy | 是否为周期购 | `Boolean` |
| show_delivery_time | 是否显示发货时间 | `Boolean` |
### Event
| 事件名 | 说明 | 参数 |
|-----------|-----------|-----------|
| clickEmptyButton | 点击商品为空时的按钮时触发 | - |
### Slot
| name | 描述 |
|-----------|-----------|

View File

@ -2,7 +2,7 @@
<div class="van-order-goods-empty">
<img :src="icon" />
<p>{{ message }}</p>
<van-button @click="onClickButton">{{ buttonText }}</van-button>
<van-button @click="$emit('clickEmptyButton')">{{ buttonText }}</van-button>
</div>
</template>
@ -20,12 +20,6 @@ export default {
icon: String,
message: String,
buttonText: String
},
methods: {
onClickButton() {
history.back();
}
}
};
</script>

View File

@ -12,6 +12,7 @@
:icon="emptyIcon"
:message="emptyMessage"
:button-text="emptyButtonText"
@clickEmptyButton="$emit('clickEmptyButton')"
/>
<div class="van-order-goods-list">
<van-order-goods-card

View File

@ -35,7 +35,7 @@ function getWebpackConfig(testFileName) {
stats: 'errors-only',
resolve: {
modules: [path.resolve(process.cwd(), 'node_modules'), 'node_modules'],
extensions: ['.js', '.json', '.vue'],
extensions: ['.js', '.json', '.vue', '.css'],
alias: {
src: path.resolve(process.cwd(), 'src'),
packages: path.resolve(process.cwd(), 'packages'),

View File

@ -76,6 +76,9 @@ describe('OrderGoods', () => {
}
});
const submitSpyFunc = sinon.spy();
wrapper.vm.$on('clickEmptyButton', submitSpyFunc);
wrapper.find('.van-button')[0].trigger('click');
DOMChecker(wrapper, {
@ -87,6 +90,8 @@ describe('OrderGoods', () => {
'.van-order-goods-empty img': 'http://b.yzcdn.cn/v2/image/wap/trade/new_order/empty@2x.png'
}
});
expect(submitSpyFunc.calledOnce).to.be.true;
});
it('empty list config', () => {
@ -110,7 +115,7 @@ describe('OrderGoods', () => {
});
});
it('edit message', () => {
it('edit message', (done) => {
wrapper = mount(OrderGoods, {
attachToDocument: true,
propsData: {
@ -120,16 +125,14 @@ describe('OrderGoods', () => {
});
wrapper.vm.$on('input', val => {
wrapper.value = val;
wrapper.vm.message = val;
expect(wrapper.vm.message).to.equal('测试留言');
done();
});
const textarea = wrapper.find('textarea')[0];
textarea.value = '测试留言';
textarea.element.value = '测试留言';
textarea.trigger('input');
wrapper.vm.$nextTick(() => {
expect(wrapper.value).to.equal('测试留言');
});
});
it('message not editable', () => {
@ -159,16 +162,10 @@ describe('OrderGoods', () => {
}
});
wrapper.vm.$on('input', val => {
wrapper.value = val;
});
wrapper.vm.$nextTick(() => {
DOMChecker(wrapper, {
text: {
'.van-order-goods-message p': '无'
}
});
DOMChecker(wrapper, {
text: {
'.van-order-goods-message p': ''
}
});
});
@ -262,7 +259,7 @@ describe('OrderGoods', () => {
});
});
it('item with message', () => {
it('item with message', (done) => {
wrapper = mount(OrderGoods, {
attachToDocument: true,
propsData: {
@ -293,6 +290,7 @@ describe('OrderGoods', () => {
}
}
});
done();
}, 300);
});