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') + }) +})