From 63f557bd69b39733338521462697755af1049be5 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 13:04:43 +0800 Subject: [PATCH] unit test: d2-container-full Former-commit-id: 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 4bc2b877ea4c3d8cfaa05554e9f9f7e5350b6e25 [formerly 70126561aeab08652824a7f17b6a570cb1e9dd87 [formerly fe236bdaadef752c31ba9c21b43ffcc4c98fbcbf]]]]] Former-commit-id: 95f590e4a7ae9f8c27ff386887f6eb53309e5e25 Former-commit-id: 6db59439578a4af63444b378eee9566211e25457 Former-commit-id: 0203ff26b3d18211749bf747b5bbe337d65c8917 [formerly cdc91f18bb39d2bbeb6c7f4553d31acc3ab89a7e] Former-commit-id: a4b0181e8181265c6763c22d6accd0796d186e8f Former-commit-id: 240d166967d9a894e38b8ba39cbb222714533ae3 Former-commit-id: 64a23cf1415c54a325976b4d35768b708c16d541 Former-commit-id: 3cc60fa0e2527105042fbcbae219acc65da95eb1 Former-commit-id: de843fe7336dd261875465bcd8e1b3be0b00d101 --- tests/unit/d2-container-full.spec.js | 54 ++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/unit/d2-container-full.spec.js diff --git a/tests/unit/d2-container-full.spec.js b/tests/unit/d2-container-full.spec.js new file mode 100644 index 00000000..39e8a744 --- /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', () => { + // 存在且是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() + }) + + // 节流间隔prop + it('has a property named \'scrollDelay\'', () => { + 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') + }) +})