Added vehicle-protected-question unit tests
This commit is contained in:
parent
7093b5a8e9
commit
07a54cbf29
5 changed files with 83 additions and 18 deletions
|
|
@ -196,5 +196,4 @@ describe("modal.vue", () => {
|
||||||
// Assert
|
// Assert
|
||||||
expect(hideMock).toHaveBeenCalled();
|
expect(hideMock).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ describe("modal.vue", () => {
|
||||||
const wrapper = shallowMount(TextBlock, {
|
const wrapper = shallowMount(TextBlock, {
|
||||||
mixins: [mockMixin],
|
mixins: [mockMixin],
|
||||||
props: {
|
props: {
|
||||||
customText: "customText"
|
customText: "customText",
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(wrapper.html()).toEqual(expect.stringContaining("customText"));
|
expect(wrapper.html()).toEqual(expect.stringContaining("customText"));
|
||||||
|
|
@ -48,7 +48,6 @@ describe("modal.vue", () => {
|
||||||
});
|
});
|
||||||
expect(wrapper.html()).toEqual(expect.stringContaining(mockProps["fontWeight"]));
|
expect(wrapper.html()).toEqual(expect.stringContaining(mockProps["fontWeight"]));
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
import { shallowMount } from "@vue/test-utils";
|
||||||
|
import vehicleProtectedQuestion from "./vehicle-protected-question";
|
||||||
|
|
||||||
|
jest.mock("@/digital-components/textbox-question/textbox-question", () => ({
|
||||||
|
getCmsContent: jest.fn(),
|
||||||
|
}));
|
||||||
|
|
||||||
|
const mockMixin = {
|
||||||
|
methods: {
|
||||||
|
getCmsContent: jest.fn((widgetName, cmsFieldName) => {
|
||||||
|
if (cmsFieldName === "Answers") {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
"AnswerImageUrl": "",
|
||||||
|
"Name": "YesAnswer",
|
||||||
|
"SubText": "",
|
||||||
|
"SubWidgetName": "",
|
||||||
|
"Text": "Yes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"AnswerImageUrl": "",
|
||||||
|
"Name": "NoAnswer",
|
||||||
|
"SubText": "",
|
||||||
|
"SubWidgetName": "",
|
||||||
|
"Text": "No"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
return "QuestionText";
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
describe("service-zip-question.vue", () => {
|
||||||
|
it("Should get the modelValue", async () => {
|
||||||
|
// Arrange
|
||||||
|
const answer = "YesAnswer";
|
||||||
|
const wrapper = shallowMount(vehicleProtectedQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: answer,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
const modelValueAnswer = wrapper.vm.selectedValue;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(modelValueAnswer).toEqual(answer);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should emit to set value", async () => {
|
||||||
|
// Arrange
|
||||||
|
const yesAnswer = "YesAnswer";
|
||||||
|
const noAnswer = "NoAnswer"
|
||||||
|
const wrapper = shallowMount(vehicleProtectedQuestion, {
|
||||||
|
mixins: [mockMixin],
|
||||||
|
props: {
|
||||||
|
modelValue: yesAnswer,
|
||||||
|
},
|
||||||
|
attachTo: document.body,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Act
|
||||||
|
wrapper.vm.selectedValue = noAnswer;
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.emitted("update:modelValue")).toEqual([[noAnswer]]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -14,7 +14,7 @@ describe("service-zip-question.vue", () => {
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const modelValueText = wrapper.vm.value;
|
const modelValueText = wrapper.vm.value;
|
||||||
wrapper.vm.value = "test also"
|
wrapper.vm.value = "test also";
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(modelValueText).toEqual("test");
|
expect(modelValueText).toEqual("test");
|
||||||
|
|
@ -32,10 +32,9 @@ describe("service-zip-question.vue", () => {
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
const modelValueText = wrapper.vm.value;
|
const modelValueText = wrapper.vm.value;
|
||||||
wrapper.vm.value = "test also"
|
wrapper.vm.value = "test also";
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.emitted("update:modelValue")).toEqual([["test also"]]);
|
expect(wrapper.emitted("update:modelValue")).toEqual([["test also"]]);
|
||||||
})
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -91,7 +91,7 @@ describe("buttonMain.vue", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
isLoaderDisplayed: true
|
isLoaderDisplayed: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -116,7 +116,7 @@ describe("buttonMain.vue", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
wrapper.setData({
|
wrapper.setData({
|
||||||
isLoaderDisplayed: true
|
isLoaderDisplayed: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -125,7 +125,6 @@ describe("buttonMain.vue", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.isLoaderDisplayed).toBe(false);
|
expect(wrapper.vm.isLoaderDisplayed).toBe(false);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should emit 'click-event' event when clicking if the button is enabled", async () => {
|
it("Should emit 'click-event' event when clicking if the button is enabled", async () => {
|
||||||
|
|
@ -136,12 +135,11 @@ describe("buttonMain.vue", () => {
|
||||||
props: {
|
props: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
isDisabled: false
|
isDisabled: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const buttonElement = wrapper.find("button");
|
const buttonElement = wrapper.find("button");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -151,7 +149,6 @@ describe("buttonMain.vue", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.emitted("click-event")).toBeTruthy();
|
expect(wrapper.emitted("click-event")).toBeTruthy();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should not emit 'click-event' event when clicking if the button is disabled", async () => {
|
it("Should not emit 'click-event' event when clicking if the button is disabled", async () => {
|
||||||
|
|
@ -162,7 +159,7 @@ describe("buttonMain.vue", () => {
|
||||||
props: {
|
props: {
|
||||||
loaderPosition: "right",
|
loaderPosition: "right",
|
||||||
loaderEnabled: true,
|
loaderEnabled: true,
|
||||||
isDisabled: true
|
isDisabled: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
@ -176,7 +173,6 @@ describe("buttonMain.vue", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.emitted("click-event")).toBeFalsy();
|
expect(wrapper.emitted("click-event")).toBeFalsy();
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue