From 100f8a51b0b8e1f7942ddf33093987b6b8128846 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 14:41:36 +0800 Subject: [PATCH] unit test: d2-source Former-commit-id: 262746d1065b9d7732492498cbaa976506d6e0bb [formerly 262746d1065b9d7732492498cbaa976506d6e0bb [formerly 262746d1065b9d7732492498cbaa976506d6e0bb [formerly 262746d1065b9d7732492498cbaa976506d6e0bb [formerly c5f1b718ada6351ba635fe3c86a30b41306e27cd [formerly 1bca35e5870d04510f1bf61312f2aa15f2415dce]]]]] Former-commit-id: 555297611afc03ee0c6735c391194254ccd14b08 Former-commit-id: 451d89d5a4805638f948b12b6ab3c5024c5cb6e2 Former-commit-id: 062d757d5cf53079bf2c83779e418d82b02ac9ed [formerly 1eabb82bb10944e675b4aedd8349ce4d63fc1438] Former-commit-id: eb7d104d3b16e1ac982c8fc5aee89c3349838579 Former-commit-id: 3bada4298c976a4de8259fbcda5eb37a40aa2ce9 Former-commit-id: 50f36cd0121628bb1a3be4840950db18894cd06c Former-commit-id: 1f4a3f28093592fc74ae971ffb5b3d5c7657ae53 Former-commit-id: dfc27342fc8c7e9a46a11160cc37ccb3d345f75f --- tests/unit/d2-source.spec.js | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 tests/unit/d2-source.spec.js diff --git a/tests/unit/d2-source.spec.js b/tests/unit/d2-source.spec.js new file mode 100644 index 00000000..31da50bf --- /dev/null +++ b/tests/unit/d2-source.spec.js @@ -0,0 +1,39 @@ +import { mount, createLocalVue } from '@vue/test-utils' +import D2Source from '@/components/d2-container/components/d2-source.vue' +import util from '@/libs/util' + +describe('d2-source.vue', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2Source, { + stubs: ['d2-icon'] + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2Source, { + stubs: ['d2-icon'] + }) + + expect(wrapper.is('.d2-source')).toBeTruthy() + setTimeout(() => { + expect(wrapper.contains('.d2-source--active')).toBeTruthy() + }, 500) + }) + + // filename prop + it('has a property named \'filename\'', () => { + const wrapper = mount(D2Source, { + stubs: ['d2-icon'], + propsData: { + filename: '' + } + }) + + expect(wrapper.props().filename).toEqual('') + }) +}) \ No newline at end of file