From 8fed8a7df94e7f464c11073cfa28fa426d6a4d73 Mon Sep 17 00:00:00 2001 From: caoxiangsong Date: Fri, 2 Sep 2022 10:27:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E8=BF=87=E4=BA=8B=E4=BB=B6=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=AE=9E=E7=8E=B0=E4=B8=80=E4=B8=AA=E7=AE=80=E5=8D=95?= =?UTF-8?q?=E7=9A=84spm=E4=BF=A1=E6=81=AF=E6=94=B6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/HelloWorld.vue | 72 +++++++++++++++++++++++++++++------ tests/unit/example.spec.js | 38 +++++++++--------- 2 files changed, 79 insertions(+), 31 deletions(-) diff --git a/src/components/HelloWorld.vue b/src/components/HelloWorld.vue index 5e4ce20..1fb2daf 100644 --- a/src/components/HelloWorld.vue +++ b/src/components/HelloWorld.vue @@ -1,11 +1,16 @@ @@ -13,13 +18,56 @@ diff --git a/tests/unit/example.spec.js b/tests/unit/example.spec.js index 4bc26e0..f0463f4 100644 --- a/tests/unit/example.spec.js +++ b/tests/unit/example.spec.js @@ -1,21 +1,21 @@ -import { shallowMount, mount } from '@vue/test-utils' -import HelloWorld from '@/components/HelloWorld.vue'; -import { warn } from 'vue'; +import { shallowMount, mount } from "@vue/test-utils"; +import HelloWorld from "@/components/HelloWorld.vue"; +import { warn } from "vue"; -jest.setTimeout(10000) -describe('HelloWorld.vue', () => { - it('校验第一个按钮的spm是否为aa.bb.cc', async () => { +jest.setTimeout(10000); +describe("HelloWorld.vue", () => { + it("校验第一个按钮的spm是否为aa.bb.cc", async () => { const wrapper = shallowMount(HelloWorld, { attachTo: document.body }); - const button = wrapper.findAll('button'); - await button[0].trigger('click'); - expect(wrapper.vm.spmText).toMatch('aa.bb.cc'); - }) -}) -describe('HelloWorld.vue', () => { - it('校验第一个按钮的spm是否为aa.dd.ff', async () => { - const wrapper = shallowMount(HelloWorld, { attachTo: document.body }) - const button = wrapper.findAll('button') - await button[1].trigger('click') - expect(wrapper.vm.spmText).toMatch('aa.dd.ff') - }) -}) \ No newline at end of file + const button = wrapper.findAll("button"); + await button[0].trigger("click"); + expect(wrapper.vm.spmText).toMatch("aa.bb.qq"); + }); +}); +describe("HelloWorld.vue", () => { + it("校验第二个按钮的spm是否为aa.dd.pp", async () => { + const wrapper = shallowMount(HelloWorld, { attachTo: document.body }); + const button = wrapper.findAll("button"); + await button[1].trigger("click"); + expect(wrapper.vm.spmText).toMatch("aa.cc.pp"); + }); +});