From f8531348701e481ad9cc2ea8fb7a82024d810513 Mon Sep 17 00:00:00 2001 From: Katie Date: Thu, 13 Oct 2022 09:58:01 -0400 Subject: [PATCH] CSR-762 tests WIP --- .../base-input-button.spec.js | 72 +++++++++++-------- 1 file changed, 41 insertions(+), 31 deletions(-) diff --git a/src/common-components/base-input-button/base-input-button.spec.js b/src/common-components/base-input-button/base-input-button.spec.js index 1cb244997..3f1b03d9c 100644 --- a/src/common-components/base-input-button/base-input-button.spec.js +++ b/src/common-components/base-input-button/base-input-button.spec.js @@ -1,5 +1,6 @@ import { shallowMount, mount } from "@vue/test-utils"; import baseInputButton from "./base-input-button"; +import inputButtonWrapperMixin from "@/mixins/input-button-wrapper-mixin" describe("baseInputButton.vue", () => { describe("general", () => { @@ -713,7 +714,7 @@ describe("baseInputButton.vue", () => { }); describe("pushClickEventToGA", () => { - test.only("pushEventToGA is called correctly", () => { + test("pushEventToGA is called correctly", () => { // Arrange const { wrapper } = setupMocks({ mockData: { @@ -721,17 +722,11 @@ describe("baseInputButton.vue", () => { value: "Bello", setLastValuePushedToGa: jest.fn(), }, - route: { - query: { - fmgPage: "myPage", - }, - }, }, }); - console.log(wrapper.vm.$route) + console.log(wrapper.vm.$route); - wrapper.vm.pushEventToGA = jest.fn(); wrapper.setData({ GaActions: { CLICKED: "Clicked", @@ -950,6 +945,25 @@ describe("baseInputButton.vue", () => { }); }); }); + + describe("integration testing", () => { + describe("checkbox", () => { + test.only("click on both => both are selected", async () => { + // Arrange + const { wrapper } = setupBaseInputButtonWrapper({ + isMultiSelect: true + }) + console.log(wrapper.html()) + + // Act + const buttonWrappers = wrapper.findAllComponents({name: "baseInputButtonWrapper"}) + await buttonWrappers[0].trigger("click") + + // Assert + expect(wrapper.vm.value).toEqual(["value1"]) + }) + }) + }); }); // TODO KO look at how I tested groups of these in SFA @@ -957,15 +971,6 @@ describe("baseInputButton.vue", () => { // that this acts like a regular input aside from a different emitted event) function setupMocks({ mockData = {}, shouldShallowMount = true }) { - const baseInputButtonWrapper = { - components: { baseInputButton }, - template: '', - data() { - return { - myValue: "", - }; - }, - }; const mountMockData = { ...mockData, propsData: { @@ -985,7 +990,9 @@ function setupMocks({ mockData = {}, shouldShallowMount = true }) { wrapper.vm.pushEventToGA = jest.fn(); wrapper.vm.$route = { - query: {}, + query: { + fmgPage: "myPage", + }, }; wrapper.vm.GaActions = {}; @@ -994,28 +1001,31 @@ function setupMocks({ mockData = {}, shouldShallowMount = true }) { function setupBaseInputButtonWrapper({ mockData = {} }) { const baseInputButtonWrapper = { + name: "baseInputButtonWrapper", components: { baseInputButton }, template: - '
', + '
Test
', data() { return { - myValue: "", isMultiSelect: mockData.isMultiSelect, }; }, - - // const parentComponent = mount({ - // data() { - // return { - // value: "value1", - // } - // }, - // template: '
', - // components: { baseInputButton } - // }) + mixins: [inputButtonWrapperMixin] }; - const wrapper = mount(baseInputButtonWrapper, {}); + let parentComponentTemplate = "
" + parentComponentTemplate += `` + parentComponentTemplate += `` + parentComponentTemplate += `
` + const wrapper = mount({ + data() { + return { + value: mockData.initialValue, + } + }, + template: parentComponentTemplate, + components: { baseInputButtonWrapper } + }) return { wrapper }; }