diff --git a/package.json b/package.json index 4fa1aa50..17d7be40 100644 --- a/package.json +++ b/package.json @@ -56,10 +56,10 @@ "@kazupon/vue-i18n-loader": "^0.3.0", "@vue/cli-plugin-babel": "^3.0.0", "@vue/cli-plugin-eslint": "^3.0.0", - "@vue/cli-plugin-unit-jest": "^3.0.0", + "@vue/cli-plugin-unit-jest": "^3.2.3", "@vue/cli-service": "^3.0.0", "@vue/eslint-config-standard": "^3.0.0", - "@vue/test-utils": "^1.0.0-beta.20", + "@vue/test-utils": "^1.0.0-beta.28", "babel-core": "7.0.0-bridge.0", "babel-jest": "^23.0.1", "lint-staged": "^7.2.0", diff --git a/tests/unit/HelloWorld.spec.js b/tests/unit/HelloWorld.spec.js deleted file mode 100644 index 566048c0..00000000 --- a/tests/unit/HelloWorld.spec.js +++ /dev/null @@ -1,14 +0,0 @@ -// 暂时 D2 没有单元测试代码 此文件为自动生成 - -import { shallowMount } from '@vue/test-utils' -import HelloWorld from '@/components/HelloWorld.vue' - -describe('HelloWorld.vue', () => { - it('renders props.msg when passed', () => { - const msg = 'new message' - const wrapper = shallowMount(HelloWorld, { - propsData: { msg } - }) - expect(wrapper.text()).toMatch(msg) - }) -}) diff --git a/tests/unit/d2-container-card-bs.spec.js b/tests/unit/d2-container-card-bs.spec.js new file mode 100644 index 00000000..cb3add27 --- /dev/null +++ b/tests/unit/d2-container-card-bs.spec.js @@ -0,0 +1,55 @@ +import { mount } from '@vue/test-utils' +import D2ContainerCardBs from '@/components/d2-container/components/d2-container-card-bs.vue' + +describe('d2-container-card-bs', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ContainerCardBs) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2ContainerCardBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.is('.d2-container-card-bs')).toBeTruthy() + expect(wrapper.contains('.d2-container-card-bs__header')).toBeTruthy() + expect(wrapper.contains('.d2-container-card-bs__body')).toBeTruthy() + expect(wrapper.contains('.d2-container-card-bs__body-card')).toBeTruthy() + expect(wrapper.contains('.d2-container-card-bs__footer')).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ContainerCardBs, { + propsData: { + betterScrollOptions: {} + } + }) + + expect(wrapper.props().betterScrollOptions).toEqual({}) + }) + + // 渲染slot + it('has one or more slots', () => { + const wrapper = mount(D2ContainerCardBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.text()).toMatch('header') + expect(wrapper.text()).toMatch('body') + expect(wrapper.text()).toMatch('footer') + }) +}) diff --git a/tests/unit/d2-container-card.spec.js b/tests/unit/d2-container-card.spec.js new file mode 100644 index 00000000..9989841d --- /dev/null +++ b/tests/unit/d2-container-card.spec.js @@ -0,0 +1,55 @@ +import { mount } from '@vue/test-utils' +import D2ContainerCard from '@/components/d2-container/components/d2-container-card.vue' + +describe('d2-container-card', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ContainerCard) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2ContainerCard, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.is('.d2-container-card')).toBeTruthy() + expect(wrapper.contains('.d2-container-card__header')).toBeTruthy() + expect(wrapper.contains('.d2-container-card__body')).toBeTruthy() + expect(wrapper.contains('.d2-container-card__body-card')).toBeTruthy() + expect(wrapper.contains('.d2-container-card__footer')).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ContainerCard, { + propsData: { + scrollDelay: 30 + } + }) + + expect(wrapper.props().scrollDelay).toEqual(30) + }) + + // 渲染slot + it('has one or more slots', () => { + const wrapper = mount(D2ContainerCard, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.text()).toMatch('header') + expect(wrapper.text()).toMatch('body') + expect(wrapper.text()).toMatch('footer') + }) +}) diff --git a/tests/unit/d2-container-frame.spec.js b/tests/unit/d2-container-frame.spec.js new file mode 100644 index 00000000..ccb5555f --- /dev/null +++ b/tests/unit/d2-container-frame.spec.js @@ -0,0 +1,35 @@ +import { mount } from '@vue/test-utils' +import D2ContainerFrame from '@/components/d2-container-frame/index.vue' + +describe('d2-container-frame', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ContainerFrame, { + stubs: ['d2-container'] + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2ContainerFrame, { + stubs: ['d2-container'] + }) + + expect(wrapper.contains('.d2-container-frame')).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ContainerFrame, { + stubs: ['d2-container'], + propsData: { + src: 'https://doc.d2admin.fairyever.com/zh/' + } + }) + + expect(wrapper.props().src).toEqual('https://doc.d2admin.fairyever.com/zh/') + }) +}) diff --git a/tests/unit/d2-container-full-bs.spec.js b/tests/unit/d2-container-full-bs.spec.js new file mode 100644 index 00000000..2ed8c72f --- /dev/null +++ b/tests/unit/d2-container-full-bs.spec.js @@ -0,0 +1,55 @@ +import { mount } from '@vue/test-utils' +import D2ContainerFullBs from '@/components/d2-container/components/d2-container-full-bs.vue' + +describe('d2-container-full-bs', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ContainerFullBs) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2ContainerFullBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.is('.d2-container-full-bs')).toBeTruthy() + expect(wrapper.contains('.d2-container-full-bs__header')).toBeTruthy() + expect(wrapper.contains('.d2-container-full-bs__body')).toBeTruthy() + expect(wrapper.contains('.d2-container-full-bs__body-wrapper-inner')).toBeTruthy() + expect(wrapper.contains('.d2-container-full-bs__footer')).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ContainerFullBs, { + propsData: { + betterScrollOptions: {} + } + }) + + expect(wrapper.props().betterScrollOptions).toEqual({}) + }) + + // 渲染slot + it('has one or more slots', () => { + const wrapper = mount(D2ContainerFullBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.text()).toMatch('header') + expect(wrapper.text()).toMatch('body') + expect(wrapper.text()).toMatch('footer') + }) +}) diff --git a/tests/unit/d2-container-full.spec.js b/tests/unit/d2-container-full.spec.js new file mode 100644 index 00000000..e187caf5 --- /dev/null +++ b/tests/unit/d2-container-full.spec.js @@ -0,0 +1,54 @@ +import { mount } from '@vue/test-utils' +import D2ContainerFull from '@/components/d2-container/components/d2-container-full.vue' + +describe('d2-container-full', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ContainerFull) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2ContainerFull, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.is('.d2-container-full')).toBeTruthy() + expect(wrapper.contains('.d2-container-full__header')).toBeTruthy() + expect(wrapper.contains('.d2-container-full__body')).toBeTruthy() + expect(wrapper.contains('.d2-container-full__footer')).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ContainerFull, { + propsData: { + scrollDelay: 30 + } + }) + + expect(wrapper.props().scrollDelay).toEqual(30) + }) + + // 渲染slot + it('has one or more slots', () => { + const wrapper = mount(D2ContainerFull, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.text()).toMatch('header') + expect(wrapper.text()).toMatch('body') + expect(wrapper.text()).toMatch('footer') + }) +}) diff --git a/tests/unit/d2-container-ghost-bs.spec.js b/tests/unit/d2-container-ghost-bs.spec.js new file mode 100644 index 00000000..7ff2d6ac --- /dev/null +++ b/tests/unit/d2-container-ghost-bs.spec.js @@ -0,0 +1,65 @@ +import { mount } from '@vue/test-utils' +import D2ContainerGhostBs from '@/components/d2-container/components/d2-container-ghost-bs.vue' + +describe('d2-container-ghost-bs', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ContainerGhostBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2ContainerGhostBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.is('.d2-container-ghost-bs')).toBeTruthy() + expect(wrapper.contains('.d2-container-ghost-bs__header')).toBeTruthy() + expect(wrapper.contains('.d2-container-ghost-bs__body')).toBeTruthy() + expect(wrapper.contains('.d2-container-ghost-bs__footer')).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ContainerGhostBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + }, + propsData: { + betterScrollOptions: {} + } + }) + + expect(wrapper.props().betterScrollOptions).toEqual({}) + }) + + // 渲染slot + it('has one or more slots', () => { + const wrapper = mount(D2ContainerGhostBs, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.text()).toMatch('header') + expect(wrapper.text()).toMatch('body') + expect(wrapper.text()).toMatch('footer') + }) +}) \ No newline at end of file diff --git a/tests/unit/d2-container-ghost.spec.js b/tests/unit/d2-container-ghost.spec.js new file mode 100644 index 00000000..2b6f0bb1 --- /dev/null +++ b/tests/unit/d2-container-ghost.spec.js @@ -0,0 +1,54 @@ +import { mount } from '@vue/test-utils' +import D2ContainerGhost from '@/components/d2-container/components/d2-container-ghost.vue' + +describe('d2-container-ghost', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ContainerGhost) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2ContainerGhost, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.is('.d2-container-ghost')).toBeTruthy() + expect(wrapper.contains('.d2-container-ghost__header')).toBeTruthy() + expect(wrapper.contains('.d2-container-ghost__body')).toBeTruthy() + expect(wrapper.contains('.d2-container-ghost__footer')).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ContainerGhost, { + propsData: { + scrollDelay: 30 + } + }) + + expect(wrapper.props().scrollDelay).toEqual(30) + }) + + // 渲染slot + it('has one or more slots', () => { + const wrapper = mount(D2ContainerGhost, { + slots: { + default: '
body
', + header: '
header
', + footer: '
footer
' + } + }) + + expect(wrapper.text()).toMatch('header') + expect(wrapper.text()).toMatch('body') + expect(wrapper.text()).toMatch('footer') + }) +}) diff --git a/tests/unit/d2-count-up.spec.js b/tests/unit/d2-count-up.spec.js new file mode 100644 index 00000000..6f8b2213 --- /dev/null +++ b/tests/unit/d2-count-up.spec.js @@ -0,0 +1,72 @@ +import { mount } from '@vue/test-utils' +import D2CountUp from '@/components/d2-count-up/index.vue' + +describe('d2-count-up', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2CountUp, { + propsData: { + end: 100 + } + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2CountUp, { + propsData: { + start: 0, + end: 100, + decimals: 0, + duration: 2, + options: {} + } + }) + + expect(wrapper.props().start).toEqual(0) + expect(wrapper.props().end).toEqual(100) + expect(wrapper.props().decimals).toEqual(0) + expect(wrapper.props().duration).toEqual(2) + expect(wrapper.props().options).toEqual({}) + }) + + // 开始数字,1秒后结束数字 + it('start number is 1, 1s later, end number is 99', (done) => { + const wrapper = mount(D2CountUp, { + propsData: { + start: 1, + end: 99, + duration: 1 + } + }) + + expect(wrapper.text()).toBe('1') + + setTimeout(() => { + expect(wrapper.text()).toBe('99') + done() + }, 1100) + }) + + // 小数位数 + it('start number is 1.00, 1s later, end number is 99.00', (done) => { + const wrapper = mount(D2CountUp, { + propsData: { + start: 1, + end: 99, + decimals: 2, + duration: 1 + } + }) + + expect(wrapper.text()).toBe('1.00') + + setTimeout(() => { + expect(wrapper.text()).toBe('99.00') + done() + }, 1100) + }) +}) diff --git a/tests/unit/d2-icon-select.spec.js b/tests/unit/d2-icon-select.spec.js new file mode 100644 index 00000000..2c67fe78 --- /dev/null +++ b/tests/unit/d2-icon-select.spec.js @@ -0,0 +1,39 @@ +import { mount, createLocalVue } from '@vue/test-utils' +import D2IconSelect from '@/components/d2-icon-select/index.vue' +import ElementUI from 'element-ui' + +describe('d2-icon-select', () => { + const localVue = createLocalVue() + localVue.use(ElementUI) + + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2IconSelect, { + stubs: ['el-popover', 'el-button', 'el-input', 'el-collapse', 'el-collapse-item', 'el-col', 'el-row'] + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // // props + // it('has props', () => { + // const wrapper = mount(D2IconSelect, { + // propsData: { + // value: 'value', + // placeholder: '请选择', + // placement: 'right', + // clearable: true, + // userInput: false, + // autoClose: false + // } + // }) + + // expect(wrapper.props().value).toEqual('value') + // expect(wrapper.props().placeholder).toEqual('请选择') + // expect(wrapper.props().placement).toEqual('right') + // expect(wrapper.props().clearable).toEqual(true) + // expect(wrapper.props().userInput).toEqual(false) + // expect(wrapper.props().autoClose).toEqual(false) + // }) +}) diff --git a/tests/unit/d2-icon-svg.spec.js b/tests/unit/d2-icon-svg.spec.js new file mode 100644 index 00000000..afcb2071 --- /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组件实例 + 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-icon.spec.js b/tests/unit/d2-icon.spec.js new file mode 100644 index 00000000..7ebc651a --- /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组件实例 + 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() + }) + + // props + it('has props', () => { + const wrapper = mount(D2Icon, { + propsData: { + name: 'font-awesome' + } + }) + + expect(wrapper.props().name).toEqual('font-awesome') + }) +}) 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') + }) +}) diff --git a/tests/unit/d2-module-index-banner.spec.js b/tests/unit/d2-module-index-banner.spec.js new file mode 100644 index 00000000..8335bdcd --- /dev/null +++ b/tests/unit/d2-module-index-banner.spec.js @@ -0,0 +1,30 @@ +import { mount } from '@vue/test-utils' +import D2ModuleIndexBanner from '@/components/d2-module-index-banner/index.vue' + +describe('d2-module-index-banner', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ModuleIndexBanner, { + stubs: ['d2-icon'] + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // props + it('has props', () => { + const wrapper = mount(D2ModuleIndexBanner, { + stubs: ['d2-icon'], + propsData: { + title: 'title', + subTitle: 'subTitle', + link: 'link' + } + }) + + expect(wrapper.props().title).toEqual('title') + expect(wrapper.props().subTitle).toEqual('subTitle') + expect(wrapper.props().link).toEqual('link') + }) +}) diff --git a/tests/unit/d2-module-index-menu.spec.js b/tests/unit/d2-module-index-menu.spec.js new file mode 100644 index 00000000..75298d71 --- /dev/null +++ b/tests/unit/d2-module-index-menu.spec.js @@ -0,0 +1,36 @@ +import { mount } from '@vue/test-utils' +import D2ModuleIndexMenu from '@/components/d2-module-index-menu/index.vue' +import menu from '@/menu/modules/demo-business' + +describe('d2-module-index-menu', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2ModuleIndexMenu, { + stubs: ['el-button'], + propsData: { + menu + } + }) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 300m后正确渲染,包含特定类名 + it('contains specific classnames', (done) => { + const wrapper = mount(D2ModuleIndexMenu, { + stubs: ['el-button'], + propsData: { + menu: menu + } + }) + + setTimeout(() => { + expect(wrapper.is('.d2-module-index-menu')).toBeTruthy() + expect(wrapper.contains('.d2-module-index-menu-group')).toBeTruthy() + expect(wrapper.contains('.d2-module-index-menu-group--title')).toBeTruthy() + expect(wrapper.contains('.d2-module-index-menu-item')).toBeTruthy() + done() + }, 400) + }) +}) diff --git a/tests/unit/d2-page-cover.spec.js b/tests/unit/d2-page-cover.spec.js new file mode 100644 index 00000000..b6b6ca22 --- /dev/null +++ b/tests/unit/d2-page-cover.spec.js @@ -0,0 +1,41 @@ +import { mount } from '@vue/test-utils' +import D2PageCover from '@/components/d2-page-cover/index.vue' + +describe('d2-page-cover', () => { + // 存在且是Vue组件实例 + it('is a vue instance', () => { + const wrapper = mount(D2PageCover) + + expect(wrapper.exists()).toBeTruthy() + expect(wrapper.isVueInstance()).toBeTruthy() + }) + + // 包含特定类名 + it('contains specific classnames', () => { + const wrapper = mount(D2PageCover, { + slots: { + default: '
default
', + footer: '
footer
' + } + }) + + expect(wrapper.is('.d2-page-cover')).toBeTruthy() + expect(wrapper.contains('.d2-page-cover__logo')).toBeTruthy() + expect(wrapper.contains('.d2-page-cover__title')).toBeTruthy() + expect(wrapper.contains('.d2-page-cover__sub-title')).toBeTruthy() + expect(wrapper.contains('.d2-page-cover__build-time')).toBeTruthy() + }) + + // 渲染slot + it('has one or more slots', () => { + const wrapper = mount(D2PageCover, { + slots: { + default: '
default
', + footer: '
footer
' + } + }) + + expect(wrapper.text()).toMatch('default') + expect(wrapper.text()).toMatch('footer') + }) +}) diff --git a/tests/unit/d2-source.spec.js b/tests/unit/d2-source.spec.js new file mode 100644 index 00000000..d00cfb98 --- /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' + +describe('d2-source', () => { + // 存在且是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', (done) => { + const wrapper = mount(D2Source, { + stubs: ['d2-icon'] + }) + + expect(wrapper.is('.d2-source')).toBeTruthy() + setTimeout(() => { + expect(wrapper.contains('.d2-source--active')).toBeTruthy() + done() + }, 600) + }) + + // props + it('has props', () => { + const wrapper = mount(D2Source, { + stubs: ['d2-icon'], + propsData: { + filename: '' + } + }) + + expect(wrapper.props().filename).toEqual('') + }) +}) \ No newline at end of file diff --git a/yarn.lock.REMOVED.git-id b/yarn.lock.REMOVED.git-id index 7c7b5986..58f48f61 100644 --- a/yarn.lock.REMOVED.git-id +++ b/yarn.lock.REMOVED.git-id @@ -1 +1 @@ -f087314ad07f2b4d7658559be7838c8dd75bf499 \ No newline at end of file +13dd0eb82ec0a73b25d0a39fe23a367f31a2aaf8 \ No newline at end of file