From df4a2491fd0e0f69adb5b9c3d6b997d277b89e92 Mon Sep 17 00:00:00 2001 From: Jason Wheeler Date: Wed, 25 Jan 2023 11:24:53 -0500 Subject: [PATCH] fixed tests --- .../address-questions.spec.js | 40 +++++++++++++++---- .../address-questions/address-questions.vue | 1 + 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/iss-components/address-questions/address-questions.spec.js b/src/iss-components/address-questions/address-questions.spec.js index 74fd7ad8..e62c0ea1 100644 --- a/src/iss-components/address-questions/address-questions.spec.js +++ b/src/iss-components/address-questions/address-questions.spec.js @@ -15,7 +15,7 @@ describe("address-questions.vue", () => { }); describe("initial state", () => { - test("Should render addressQuestions sub-components (textbox-questions and dropdown-questions)", async () => { + test("Should hide addressQuestions sub-components (textbox-questions and dropdown-questions)", async () => { // Arrange const { wrapper } = setupMocks({}); @@ -24,17 +24,16 @@ describe("address-questions.vue", () => { const city = wrapper.findComponent({ ref: "city" }); const state = wrapper.findComponent({ ref: "state" }); const zipCode = wrapper.findComponent({ ref: "zipCode" }); + const streetAddress2 = wrapper.findComponent({ ref: "streetAddress2"}); // Assert expect(streetAddress.exists()).toBe(true); - expect(city.exists()).toBe(true); - expect(state.exists()).toBe(true); - expect(zipCode.exists()).toBe(true); + expect(city.exists()).toBe(false); + expect(state.exists()).toBe(false); + expect(zipCode.exists()).toBe(false); + expect(streetAddress2.exists()).toBe(false); }); - }); - - describe("happy paths", () => { test("full street address is passed in => address fields are displayed", async () => { // Arrange/Act const { wrapper } = setupMocks({ @@ -45,6 +44,7 @@ describe("address-questions.vue", () => { state: "OH", zipCode: "12312", }, + includeStreetAddress2: true, }, }); @@ -54,14 +54,40 @@ describe("address-questions.vue", () => { const cityField = wrapper.findComponent({ ref: "city" }); const stateField = wrapper.findComponent({ ref: "state" }); const zipField = wrapper.findComponent({ ref: "zipCode" }); + const streetAddress2 = wrapper.findComponent({ ref: "streetAddress2"}); + expect(cityField.exists()).toBeTruthy(); expect(cityField.isVisible()).toBeTruthy(); expect(stateField.exists()).toBeTruthy(); expect(cityField.isVisible()).toBeTruthy(); expect(zipField.exists()).toBeTruthy(); expect(cityField.isVisible()).toBeTruthy(); + expect(streetAddress2.isVisible()).toBeTruthy(); }); + test("address2 is hidden if includeStreetAddress2 is false", async () => { + // Arrange/Act + const { wrapper } = setupMocks({ + props: { + modelValue: { + streetAddress: "12345 Test Road", + city: "Tests", + state: "OH", + zipCode: "12312", + }, + includeStreetAddress2: false, + }, + }); + + await wrapper.vm.$nextTick(); + + // Assert + const streetAddress2 = wrapper.findComponent({ ref: "streetAddress2"}); + expect(streetAddress2.exists()).toBe(false); + }); + }); + + describe("happy paths", () => { test("street address is entered, user chooses good result from autocomplete results => other fields are filled in", async () => { // Arrange const { wrapper } = setupMocks({}); diff --git a/src/iss-components/address-questions/address-questions.vue b/src/iss-components/address-questions/address-questions.vue index 8208f6ce..f3a440aa 100644 --- a/src/iss-components/address-questions/address-questions.vue +++ b/src/iss-components/address-questions/address-questions.vue @@ -21,6 +21,7 @@