From 6fa832755610b2c190321c0cb32211679e25dcff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=98=8A=E7=BF=94?= <673686754@qq.com> Date: Sat, 5 Jan 2019 10:16:55 +0800 Subject: [PATCH] unit test: d2-icon-svg d2-link-btn Former-commit-id: dac4516bf2f7c18c06310115e800c891f6f2ad6e [formerly dac4516bf2f7c18c06310115e800c891f6f2ad6e [formerly dac4516bf2f7c18c06310115e800c891f6f2ad6e [formerly dac4516bf2f7c18c06310115e800c891f6f2ad6e [formerly 69f4a652a91a6406e85af9f56d75e0deff6049bf [formerly e8da4ed40da1a6a5f57938914fc114cbae50ef56]]]]] Former-commit-id: c84524e9212d0b3b11a01d0baa529af73bb2874f Former-commit-id: 64e446eac758226d57ce5b02700596f8b1be9c3e Former-commit-id: 9568c8329ed51f5c1367f61fc3ae59c8a2bcc67b [formerly 7d97100ddbd1c3bfbb88d560f83cec595d313b87] Former-commit-id: 4ef6a34396e0a80837a462b6bc199eb49e66db2e Former-commit-id: 8913eff75dff0dbf1c035733a5411cb79b07dffa Former-commit-id: eef91026b0942b2267315cf1a8eb73c8b5622525 Former-commit-id: 12280ec0c000ccc4d39c7e99dacec12ddce920d0 Former-commit-id: d8031829cdf409c4524ce107480937ea8ba71bac --- tests/unit/d2-icon-svg.spec.js | 27 +++++++++++++++++++++++++++ tests/unit/d2-link-btn.spec.js | 30 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 tests/unit/d2-icon-svg.spec.js create mode 100644 tests/unit/d2-link-btn.spec.js diff --git a/tests/unit/d2-icon-svg.spec.js b/tests/unit/d2-icon-svg.spec.js new file mode 100644 index 00000000..69f32043 --- /dev/null +++ b/tests/unit/d2-icon-svg.spec.js @@ -0,0 +1,27 @@ +import { mount } from '@vue/test-utils' +import D2IconSvg from '@/components/d2-icon-svg/index.vue' + +describe('d2-icon-svg.vue', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2IconSvg, { + propsData: { + name: 'add' + } + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2IconSvg, { + propsData: { + name: 'add' + } + }) + + expect(wrapper.props().name).toEqual('add') + }) +}) diff --git a/tests/unit/d2-link-btn.spec.js b/tests/unit/d2-link-btn.spec.js new file mode 100644 index 00000000..1539cd87 --- /dev/null +++ b/tests/unit/d2-link-btn.spec.js @@ -0,0 +1,30 @@ +import { mount } from '@vue/test-utils' +import D2LinkBtn from '@/components/d2-link-btn/index.vue' + +describe('d2-link-btn', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2LinkBtn, { + stubs: ['el-button-group', 'el-button', 'd2-icon'] + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2LinkBtn, { + stubs: ['el-button-group', 'el-button', 'd2-icon'], + propsData: { + title: 'title', + icon: 'icon', + link: 'link' + } + }) + + expect(wrapper.props().title).toEqual('title') + expect(wrapper.props().icon).toEqual('icon') + expect(wrapper.props().link).toEqual('link') + }) +})