CSR-762 Fix tests
This commit is contained in:
parent
dcd35f1724
commit
afa94625f7
6 changed files with 86 additions and 53 deletions
|
|
@ -215,33 +215,28 @@ describe("baseInputButton.vue", () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test("focus and click enter on a radio button => inputButtonClicked is emitted with correct value", async () => {
|
||||||
"focus and click enter on a radio button => inputButtonClicked is emitted with correct value",
|
// Arrange
|
||||||
async () => {
|
const { wrapper } = setupMocks({
|
||||||
// Arrange
|
mockData: {
|
||||||
const { wrapper } = setupMocks({
|
propsData: {
|
||||||
mockData: {
|
isMultiSelect: false,
|
||||||
propsData: {
|
value: "Hi",
|
||||||
isMultiSelect: false,
|
|
||||||
value: "Hi",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const input = wrapper.find("input");
|
const input = wrapper.find("input");
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await input.trigger("keypress", { key: "enter" });
|
await input.trigger("keypress", { key: "enter" });
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.emitted()).toHaveProperty(
|
expect(wrapper.emitted()).toHaveProperty("inputButtonClicked");
|
||||||
"inputButtonClicked"
|
expect(wrapper.emitted()["inputButtonClicked"][0][0]).toEqual(
|
||||||
);
|
"Hi"
|
||||||
expect(
|
);
|
||||||
wrapper.emitted()["inputButtonClicked"][0][0]
|
});
|
||||||
).toEqual("Hi");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -249,27 +244,33 @@ describe("baseInputButton.vue", () => {
|
||||||
describe("handleEventAction", () => {});
|
describe("handleEventAction", () => {});
|
||||||
|
|
||||||
describe("handleSelectionChange", () => {
|
describe("handleSelectionChange", () => {
|
||||||
test.todo("handleChange is called with valueToEmit")
|
test.todo("handleChange is called with valueToEmit");
|
||||||
|
|
||||||
describe("checkbox", () => {
|
describe("checkbox", () => {
|
||||||
test.todo("modelValue is null => valueToEmit is correct value")
|
test.todo("modelValue is null => valueToEmit is correct value");
|
||||||
|
|
||||||
test.todo("modelValue is undefined => valueToEmit is correct value")
|
test.todo(
|
||||||
test.todo("modelValue is empty => valueToEmit is correct value")
|
"modelValue is undefined => valueToEmit is correct value"
|
||||||
|
);
|
||||||
|
test.todo(
|
||||||
|
"modelValue is empty => valueToEmit is correct value"
|
||||||
|
);
|
||||||
|
|
||||||
test.todo("modelValue is not empty and does not contain this button's value => valueToEmit is correct value")
|
test.todo(
|
||||||
test.todo("modelValue is not empty and does contain this button's value => valueToEmit is correct value")
|
"modelValue is not empty and does not contain this button's value => valueToEmit is correct value"
|
||||||
})
|
);
|
||||||
|
test.todo(
|
||||||
|
"modelValue is not empty and does contain this button's value => valueToEmit is correct value"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
describe("radio", () => {
|
describe("radio", () => {});
|
||||||
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("handleClick", () => {
|
describe("handleClick", () => {
|
||||||
test.todo("handleSelectChange is also called")
|
test.todo("handleSelectChange is also called");
|
||||||
|
|
||||||
test.todo("inputButtonClicked is emitted with valueToEmit")
|
test.todo("inputButtonClicked is emitted with valueToEmit");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -490,6 +491,7 @@ function setupMocks({ mockData = {}, shouldShallowMount = true }) {
|
||||||
groupName: "groupName",
|
groupName: "groupName",
|
||||||
modelValue: mockData.propsData?.isMultiSelect ? [] : "",
|
modelValue: mockData.propsData?.isMultiSelect ? [] : "",
|
||||||
value: "5",
|
value: "5",
|
||||||
|
setLastValuePushedToGa: () => {},
|
||||||
// should override the above if they exist
|
// should override the above if they exist
|
||||||
...mockData.propsData,
|
...mockData.propsData,
|
||||||
},
|
},
|
||||||
|
|
@ -499,6 +501,12 @@ function setupMocks({ mockData = {}, shouldShallowMount = true }) {
|
||||||
? shallowMount(baseInputButton, mountMockData)
|
? shallowMount(baseInputButton, mountMockData)
|
||||||
: mount(baseInputButton, mountMockData);
|
: mount(baseInputButton, mountMockData);
|
||||||
|
|
||||||
|
wrapper.vm.pushEventToGA = jest.fn();
|
||||||
|
wrapper.vm.$route = {
|
||||||
|
query: {},
|
||||||
|
};
|
||||||
|
wrapper.vm.GaActions = {}
|
||||||
|
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ export default {
|
||||||
},
|
},
|
||||||
buttonId() {
|
buttonId() {
|
||||||
return `${this.groupName?.replace(" ", "-")}-${this.value
|
return `${this.groupName?.replace(" ", "-")}-${this.value
|
||||||
.toString()
|
?.toString()
|
||||||
?.replace(" ", "-")}`;
|
?.replace(" ", "-")}`;
|
||||||
},
|
},
|
||||||
isValueSelectedOnClick() {
|
isValueSelectedOnClick() {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ describe("replace-options-question.vue", () => {
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.$options.methods.updateSelectedValues.call(wrapper.vm);
|
wrapper.vm.$options.methods.updateSelectedValues.call(wrapper.vm);
|
||||||
|
|
||||||
expect(wrapper.vm.selectedReplaceOptions).toEqual([]);
|
expect(wrapper.vm.selectedValues).toEqual([]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,16 @@ describe("vehicle-parts.vue", () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(wrapper.vm.glassParts).toEqual({ "Rear-Stationary": { "Rear": ['DB12209YPYNOEM'] } });
|
expect(wrapper.vm.glassParts).toEqual({
|
||||||
|
"Rear-Stationary": {
|
||||||
|
partNumber: "DB12209YPYNOEM",
|
||||||
|
description: "heated glass, solar, 1 hole",
|
||||||
|
color: "Gray Tint Privacy",
|
||||||
|
requiresRecalibration: false,
|
||||||
|
requiresCapabilityQuestions: false,
|
||||||
|
childParts: null
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("User had part questions > BackButtonAction triggers a router.navigateWithoutSaving change with correct scenario", async () => {
|
test("User had part questions > BackButtonAction triggers a router.navigateWithoutSaving change with correct scenario", async () => {
|
||||||
|
|
@ -509,6 +518,8 @@ function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {}
|
||||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||||
|
// wrapper.vm.$refs.onSubmit = jest.fn();
|
||||||
|
// wrapper.vm.$refs.onInvalidSubmit = jest.fn();
|
||||||
|
|
||||||
return { wrapper, apiPromise };
|
return { wrapper, apiPromise };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ describe("list-card.vue", () => {
|
||||||
groupID: "checkbox-demo-1",
|
groupID: "checkbox-demo-1",
|
||||||
groupName: "Checkbox 1",
|
groupName: "Checkbox 1",
|
||||||
buttonImage: "windshield-damage.svg",
|
buttonImage: "windshield-damage.svg",
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -32,6 +33,7 @@ describe("list-card.vue", () => {
|
||||||
groupID: "radio-demo-1",
|
groupID: "radio-demo-1",
|
||||||
groupName: "radio 1",
|
groupName: "radio 1",
|
||||||
buttonImage: "windshield-damage.svg",
|
buttonImage: "windshield-damage.svg",
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -51,6 +53,7 @@ describe("list-card.vue", () => {
|
||||||
groupName: "radio 1",
|
groupName: "radio 1",
|
||||||
buttonImage: "windshield-damage.svg",
|
buttonImage: "windshield-damage.svg",
|
||||||
buttonLabelSubCopy: "Test",
|
buttonLabelSubCopy: "Test",
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -70,6 +73,7 @@ describe("list-card.vue", () => {
|
||||||
groupName: "radio 1",
|
groupName: "radio 1",
|
||||||
buttonImage: "windshield-damage.svg",
|
buttonImage: "windshield-damage.svg",
|
||||||
buttonLabelSubCopy: "Test",
|
buttonLabelSubCopy: "Test",
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -89,6 +93,7 @@ describe("list-card.vue", () => {
|
||||||
groupName: "radio 1",
|
groupName: "radio 1",
|
||||||
buttonImage: "windshield-damage.svg",
|
buttonImage: "windshield-damage.svg",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -110,6 +115,7 @@ describe("list-card.vue", () => {
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
isWide: true,
|
isWide: true,
|
||||||
buttonLabelSubCopy: "",
|
buttonLabelSubCopy: "",
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -134,6 +140,7 @@ describe("list-card.vue", () => {
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
isWide: true,
|
isWide: true,
|
||||||
buttonLabelSubCopy: "Button Subcopy",
|
buttonLabelSubCopy: "Button Subcopy",
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -159,6 +166,7 @@ describe("list-card.vue", () => {
|
||||||
buttonImage: "windshield-damage.svg",
|
buttonImage: "windshield-damage.svg",
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
isWide: false,
|
isWide: false,
|
||||||
|
value: "test value",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,16 @@ import inputButtonWrapperMixin from "@/mixins/input-button-wrapper-mixin";
|
||||||
describe("radio.vue", () => {
|
describe("radio.vue", () => {
|
||||||
it("Should have correct group name", async () => {
|
it("Should have correct group name", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
let { wrapper } = setupMocks({});
|
let { wrapper } = setupMocks({
|
||||||
|
mountOptionsMockData: {
|
||||||
|
propsData: {
|
||||||
|
groupName: "radio-button-test",
|
||||||
|
value: "test value",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.setProps({
|
|
||||||
groupName: "radio-button-test",
|
|
||||||
});
|
|
||||||
const input = wrapper.find("input");
|
const input = wrapper.find("input");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
@ -20,12 +24,16 @@ describe("radio.vue", () => {
|
||||||
|
|
||||||
it("Should have correct label text", async () => {
|
it("Should have correct label text", async () => {
|
||||||
// Act
|
// Act
|
||||||
let { wrapper } = setupMocks({});
|
let { wrapper } = setupMocks({
|
||||||
|
mountOptionsMockData: {
|
||||||
|
propsData: {
|
||||||
|
buttonLabel: "label text",
|
||||||
|
value: "test value",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
await wrapper.setProps({
|
|
||||||
buttonLabel: "label text",
|
|
||||||
});
|
|
||||||
const paragraph = wrapper.find("p");
|
const paragraph = wrapper.find("p");
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|
@ -39,6 +47,7 @@ describe("radio.vue", () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
await wrapper.setProps({
|
await wrapper.setProps({
|
||||||
screenReaderOnlyText: "screenreader text",
|
screenReaderOnlyText: "screenreader text",
|
||||||
|
value: "test value",
|
||||||
});
|
});
|
||||||
const paragraph = wrapper.find(".sr-only");
|
const paragraph = wrapper.find(".sr-only");
|
||||||
|
|
||||||
|
|
@ -48,13 +57,10 @@ describe("radio.vue", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({ mountOptionsMockData = {} }) {
|
function setupMocks({ mountOptionsMockData = {} }) {
|
||||||
const wrapper = mount(
|
const wrapper = mount(radio, {
|
||||||
radio,
|
...mountOptionsMockData,
|
||||||
getMountOptions({
|
mixins: [inputButtonWrapperMixin],
|
||||||
...mountOptionsMockData,
|
});
|
||||||
mixins: [inputButtonWrapperMixin],
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
return { wrapper };
|
return { wrapper };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue