diff --git a/test/unit/components/field.vue b/test/unit/components/field.vue
new file mode 100644
index 000000000..581a0e88e
--- /dev/null
+++ b/test/unit/components/field.vue
@@ -0,0 +1,18 @@
+
+
+ icon
+
+
+
+
+
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();
+ });
});