52 lines
1.7 KiB
JavaScript
52 lines
1.7 KiB
JavaScript
import { shallowMount } from "@vue/test-utils";
|
|
import { nextTick } from "vue";
|
|
import { getMountOptions } from "@/helpers/unitTestHelper.js";
|
|
import { storeActions } from "@/constants/storeActions.js";
|
|
import selectYear from "./selectYear.vue";
|
|
|
|
describe("selectYear.vue", () => {
|
|
test("Should render the 'pageHeader.Text' data value 'text' prop value for the Header component, 'radioQuestion.Question' data value as 'questionText' prop value for the 'radioQuestion' component and 'years' values for 'answers' prop values for the 'radioQuestion' component.", async () => {
|
|
// Arrange
|
|
const mockDataAndAction = {
|
|
actionList: [
|
|
{
|
|
actionName: storeActions.GET_PAGE_DATA,
|
|
data: {
|
|
Result: [
|
|
{
|
|
Type: "PageHeadingWidget",
|
|
Model: {
|
|
Text: "Mock Data",
|
|
},
|
|
},
|
|
{
|
|
Type: "RadioQuestionWidget",
|
|
Model: {
|
|
Question: "Mock Data",
|
|
},
|
|
},
|
|
],
|
|
},
|
|
},
|
|
{
|
|
actionName: storeActions.GET_VEHICLE_YEARS,
|
|
data: ["2023", "2022", "2021"],
|
|
},
|
|
],
|
|
};
|
|
|
|
const mountOptions = getMountOptions(mockDataAndAction);
|
|
|
|
// Act
|
|
const wrapper = shallowMount(selectYear, mountOptions);
|
|
await nextTick();
|
|
|
|
// Assert
|
|
const header = await wrapper.find(".Header");
|
|
expect(header.attributes("text")).toEqual("Mock Data");
|
|
|
|
const radioQuestion = await wrapper.findComponent(".radioQuestion");
|
|
expect(radioQuestion.attributes("answers")).toEqual("2023,2022,2021");
|
|
expect(radioQuestion.attributes("questiontext")).toEqual("Mock Data");
|
|
});
|
|
});
|