From 5e84e2e9cb9f97888faa1ecb0df4fa608c18a2f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Tue, 5 Sep 2017 10:00:09 +0800 Subject: [PATCH 1/5] Doc: fix some incorrect titles --- docs/examples-docs/goods-action.md | 2 +- docs/examples-docs/order-goods.md | 1 + docs/examples-docs/pay-order.md | 2 +- docs/examples-docs/toast.md | 25 ------------------------- 4 files changed, 3 insertions(+), 27 deletions(-) diff --git a/docs/examples-docs/goods-action.md b/docs/examples-docs/goods-action.md index 328a48951..c4e65e574 100644 --- a/docs/examples-docs/goods-action.md +++ b/docs/examples-docs/goods-action.md @@ -21,7 +21,7 @@ export default { } -## GoodsAction 商品操作组件 +## GoodsAction 商品操作 ### 使用指南 ``` javascript diff --git a/docs/examples-docs/order-goods.md b/docs/examples-docs/order-goods.md index 2d85a2a38..12256d736 100644 --- a/docs/examples-docs/order-goods.md +++ b/docs/examples-docs/order-goods.md @@ -134,6 +134,7 @@ export default { :price="1050" :item-list="itemList3" /> +``` ```javascript export default { diff --git a/docs/examples-docs/pay-order.md b/docs/examples-docs/pay-order.md index 8e9608b06..65302441e 100644 --- a/docs/examples-docs/pay-order.md +++ b/docs/examples-docs/pay-order.md @@ -1,4 +1,4 @@ -## PayOrder 支付订单 +## PayOrder 提交订单栏 + diff --git a/test/unit/specs/field.spec.js b/test/unit/specs/field.spec.js index 47e8a8b7d..9b38bf891 100644 --- a/test/unit/specs/field.spec.js +++ b/test/unit/specs/field.spec.js @@ -1,4 +1,5 @@ import Field from 'packages/field'; +import FieldWithIcon from '../components/field'; import { mount } from 'avoriaz'; describe('Field', () => { @@ -126,4 +127,43 @@ describe('Field', () => { done(); }, 500); }); + + it('show icon when has value and icon props', () => { + wrapper = mount(Field, { + propsData: { + icon: 'name', + value: '123' + } + }); + + expect(wrapper.find('.van-field__icon').length).to.equal(1); + }); + + it('create a field with icon slot', () => { + const fn = sinon.spy(); + + wrapper = mount(FieldWithIcon, { + propsData: { + onIconClick: fn + } + }); + + wrapper.find('.van-field__icon')[0].trigger('click'); + expect(fn.calledOnce).to.be.true; + }); + + it('blur event', (done) => { + const blur = sinon.spy(); + const clickIcon = sinon.spy(); + + wrapper = mount(FieldWithIcon, {}); + wrapper.vm.$on('blur', blur); + + wrapper.find('.van-field__icon')[0].trigger('click'); + wrapper.find('.van-field__control')[0].trigger('blur'); + + expect(blur.calledOnce).to.be.true; + expect(clickIcon.calledOnce).to.be.false; + done(); + }); });