From bfe800de383caf40f94e556d6aeece14225e53b6 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 2 Dec 2021 16:16:00 -0500 Subject: [PATCH] Updating unit testing --- .../radio-question/radio-question.vue | 1 + .../year-question/year-question.spec.js | 26 +++++++------------ .../year-question/year-question.vue | 20 ++++---------- 3 files changed, 15 insertions(+), 32 deletions(-) diff --git a/src/common-components/radio-question/radio-question.vue b/src/common-components/radio-question/radio-question.vue index 5d870f521..aaf06d562 100644 --- a/src/common-components/radio-question/radio-question.vue +++ b/src/common-components/radio-question/radio-question.vue @@ -16,6 +16,7 @@ sizeInRem="1.5" data-test="radio" groupName="radio-list" + textPosition="text-start" /> diff --git a/src/layouts/vehicle-year/year-question/year-question.spec.js b/src/layouts/vehicle-year/year-question/year-question.spec.js index d11572303..d3e5ccc5e 100644 --- a/src/layouts/vehicle-year/year-question/year-question.spec.js +++ b/src/layouts/vehicle-year/year-question/year-question.spec.js @@ -1,31 +1,23 @@ -import { shallowMount, flushPromises } from "@vue/test-utils"; -import { getMountOptions } from "@/helpers/unit-test-helper.js"; -import { storeActions } from "@/constants/store-actions.js"; +import { shallowMount } from "@vue/test-utils"; import yearQuestion from "@/layouts/vehicle-year/year-question/year-question"; import store from "@/store"; describe('year-question.vue', () => { - test('year-question should call API to get years', async () => { - // Arrange - const mockDataAndAction = { - actionList: [{ actionName: storeActions.GET_VEHICLE_YEARS, data: ["2023", "2022", "2021"], - }, - ], - }; - - const mountOptions = getMountOptions(mockDataAndAction); - + test('year-question should take a prop for years and questionText, and trigger a selectYear function when an option is clicked.', async () => { + // Act - const wrapper = shallowMount(yearQuestion, mountOptions); - await wrapper.setProps({questionText: 'What year is your vehicle?'}) - await flushPromises(); + const wrapper = shallowMount(yearQuestion, global); + await wrapper.setProps({ + questionText: 'What year is your vehicle?', + years: ['2023', '2022', '2021'] + }); wrapper.vm.selectYear(2020); // Assert const radioQuestion = await wrapper.findComponent({name: 'radioQuestion'}); expect(radioQuestion.attributes('questiontext')).toBe("What year is your vehicle?"); - expect(radioQuestion.attributes('answers')).toBe('2023,2022,2021'); + expect(radioQuestion.attributes('answers')).toBe("2023,2022,2021"); expect(store.state.order.vehicle.year).toBe(2020); }); }); diff --git a/src/layouts/vehicle-year/year-question/year-question.vue b/src/layouts/vehicle-year/year-question/year-question.vue index 242f44365..7be9d47f8 100644 --- a/src/layouts/vehicle-year/year-question/year-question.vue +++ b/src/layouts/vehicle-year/year-question/year-question.vue @@ -8,6 +8,9 @@