From 4ef91111e30e93a353e96e585ad1bf01aed23d17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=98=8A=E7=BF=94?= <673686754@qq.com> Date: Fri, 4 Jan 2019 15:26:25 +0800 Subject: [PATCH] unit test: d2-count-up d2-icon Former-commit-id: 7fad78a4b7f62ebe674342e8154f4497b79c5b06 [formerly 7fad78a4b7f62ebe674342e8154f4497b79c5b06 [formerly 7fad78a4b7f62ebe674342e8154f4497b79c5b06 [formerly 7fad78a4b7f62ebe674342e8154f4497b79c5b06 [formerly e6036f61ab8105232d3e57f6c84182c092a74fd1 [formerly 17cf5e498be64a1c9b05456ff022241537957376]]]]] Former-commit-id: c7f917c0128ec8867cd96710c7bcceba63c62dfd Former-commit-id: 9dff6eabb4254aa4e4807a58c961532dc5d8b47e Former-commit-id: 68bd970afdebd5c56bd0e72ffe871d687eccee69 [formerly 534cc268a850f9743ea398eae910dd1419b3b497] Former-commit-id: eace96ad1ee3407d93f3a87385fc13d6ee1936c3 Former-commit-id: c448d93d9f03dee110afba702f83e77cb36002dc Former-commit-id: bfefc7d1f57c67106a4da79e77682e33804630ed Former-commit-id: 65193bd67cb7775646fead1ecc77250cd5427d50 Former-commit-id: 20df260fbe97beba5badc5e31af3131ad510a7b2 --- tests/unit/d2-count-up.spec.js | 16 ++++++++++++++++ tests/unit/d2-icon.spec.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 tests/unit/d2-count-up.spec.js create mode 100644 tests/unit/d2-icon.spec.js diff --git a/tests/unit/d2-count-up.spec.js b/tests/unit/d2-count-up.spec.js new file mode 100644 index 00000000..ce5e292a --- /dev/null +++ b/tests/unit/d2-count-up.spec.js @@ -0,0 +1,16 @@ +import { mount } from '@vue/test-utils' +import D2CountUp from '@/components/d2-count-up/index.vue' + +describe('d2-count-up.vue', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2CountUp, { + propsData: { + end: 100 + } + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) +}) diff --git a/tests/unit/d2-icon.spec.js b/tests/unit/d2-icon.spec.js new file mode 100644 index 00000000..e07e86b8 --- /dev/null +++ b/tests/unit/d2-icon.spec.js @@ -0,0 +1,31 @@ +import { mount } from '@vue/test-utils' +import D2Icon from '@/components/d2-icon/index.vue' + +describe('d2-icon.vue', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2Icon) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2Icon) + + expect(wrapper.is('.fa')).toBeTruthy() + expect(wrapper.contains('.fa-font-awesome')).toBeTruthy() + }) + + // name prop + it('has a property named \'name\'', () => { + const wrapper = mount(D2Icon, { + propsData: { + name: 'font-awesome' + } + }) + + expect(wrapper.props().name).toEqual('font-awesome') + }) +})