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(
|
||||
"focus and click enter on a radio button => inputButtonClicked is emitted with correct value",
|
||||
async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({
|
||||
mockData: {
|
||||
propsData: {
|
||||
isMultiSelect: false,
|
||||
value: "Hi",
|
||||
},
|
||||
test("focus and click enter on a radio button => inputButtonClicked is emitted with correct value", async () => {
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({
|
||||
mockData: {
|
||||
propsData: {
|
||||
isMultiSelect: false,
|
||||
value: "Hi",
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const input = wrapper.find("input");
|
||||
const input = wrapper.find("input");
|
||||
|
||||
// Act
|
||||
await input.trigger("keypress", { key: "enter" });
|
||||
// Act
|
||||
await input.trigger("keypress", { key: "enter" });
|
||||
|
||||
// Assert
|
||||
expect(wrapper.emitted()).toHaveProperty(
|
||||
"inputButtonClicked"
|
||||
);
|
||||
expect(
|
||||
wrapper.emitted()["inputButtonClicked"][0][0]
|
||||
).toEqual("Hi");
|
||||
}
|
||||
);
|
||||
// Assert
|
||||
expect(wrapper.emitted()).toHaveProperty("inputButtonClicked");
|
||||
expect(wrapper.emitted()["inputButtonClicked"][0][0]).toEqual(
|
||||
"Hi"
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
@ -249,27 +244,33 @@ describe("baseInputButton.vue", () => {
|
|||
describe("handleEventAction", () => {});
|
||||
|
||||
describe("handleSelectionChange", () => {
|
||||
test.todo("handleChange is called with valueToEmit")
|
||||
test.todo("handleChange is called with valueToEmit");
|
||||
|
||||
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("modelValue is empty => valueToEmit is correct value")
|
||||
test.todo(
|
||||
"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("modelValue is not empty and does contain this button's value => valueToEmit is correct value")
|
||||
})
|
||||
test.todo(
|
||||
"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", () => {
|
||||
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",
|
||||
modelValue: mockData.propsData?.isMultiSelect ? [] : "",
|
||||
value: "5",
|
||||
setLastValuePushedToGa: () => {},
|
||||
// should override the above if they exist
|
||||
...mockData.propsData,
|
||||
},
|
||||
|
|
@ -499,6 +501,12 @@ function setupMocks({ mockData = {}, shouldShallowMount = true }) {
|
|||
? shallowMount(baseInputButton, mountMockData)
|
||||
: mount(baseInputButton, mountMockData);
|
||||
|
||||
wrapper.vm.pushEventToGA = jest.fn();
|
||||
wrapper.vm.$route = {
|
||||
query: {},
|
||||
};
|
||||
wrapper.vm.GaActions = {}
|
||||
|
||||
return { wrapper };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,7 @@ export default {
|
|||
},
|
||||
buttonId() {
|
||||
return `${this.groupName?.replace(" ", "-")}-${this.value
|
||||
.toString()
|
||||
?.toString()
|
||||
?.replace(" ", "-")}`;
|
||||
},
|
||||
isValueSelectedOnClick() {
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ describe("replace-options-question.vue", () => {
|
|||
//Act
|
||||
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();
|
||||
|
||||
//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 () => {
|
||||
|
|
@ -509,6 +518,8 @@ function setupMocks({ pageHeaderWidgetHeaderText = {}, mountOptionsMockData = {}
|
|||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||
// wrapper.vm.$refs.onSubmit = jest.fn();
|
||||
// wrapper.vm.$refs.onInvalidSubmit = jest.fn();
|
||||
|
||||
return { wrapper, apiPromise };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ describe("list-card.vue", () => {
|
|||
groupID: "checkbox-demo-1",
|
||||
groupName: "Checkbox 1",
|
||||
buttonImage: "windshield-damage.svg",
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ describe("list-card.vue", () => {
|
|||
groupID: "radio-demo-1",
|
||||
groupName: "radio 1",
|
||||
buttonImage: "windshield-damage.svg",
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -51,6 +53,7 @@ describe("list-card.vue", () => {
|
|||
groupName: "radio 1",
|
||||
buttonImage: "windshield-damage.svg",
|
||||
buttonLabelSubCopy: "Test",
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -70,6 +73,7 @@ describe("list-card.vue", () => {
|
|||
groupName: "radio 1",
|
||||
buttonImage: "windshield-damage.svg",
|
||||
buttonLabelSubCopy: "Test",
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -89,6 +93,7 @@ describe("list-card.vue", () => {
|
|||
groupName: "radio 1",
|
||||
buttonImage: "windshield-damage.svg",
|
||||
isRequired: true,
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -110,6 +115,7 @@ describe("list-card.vue", () => {
|
|||
isRequired: true,
|
||||
isWide: true,
|
||||
buttonLabelSubCopy: "",
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -134,6 +140,7 @@ describe("list-card.vue", () => {
|
|||
isRequired: true,
|
||||
isWide: true,
|
||||
buttonLabelSubCopy: "Button Subcopy",
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
@ -159,6 +166,7 @@ describe("list-card.vue", () => {
|
|||
buttonImage: "windshield-damage.svg",
|
||||
isRequired: true,
|
||||
isWide: false,
|
||||
value: "test value",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,16 @@ import inputButtonWrapperMixin from "@/mixins/input-button-wrapper-mixin";
|
|||
describe("radio.vue", () => {
|
||||
it("Should have correct group name", async () => {
|
||||
// Arrange
|
||||
let { wrapper } = setupMocks({});
|
||||
let { wrapper } = setupMocks({
|
||||
mountOptionsMockData: {
|
||||
propsData: {
|
||||
groupName: "radio-button-test",
|
||||
value: "test value",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Act
|
||||
await wrapper.setProps({
|
||||
groupName: "radio-button-test",
|
||||
});
|
||||
const input = wrapper.find("input");
|
||||
|
||||
// Assert
|
||||
|
|
@ -20,12 +24,16 @@ describe("radio.vue", () => {
|
|||
|
||||
it("Should have correct label text", async () => {
|
||||
// Act
|
||||
let { wrapper } = setupMocks({});
|
||||
let { wrapper } = setupMocks({
|
||||
mountOptionsMockData: {
|
||||
propsData: {
|
||||
buttonLabel: "label text",
|
||||
value: "test value",
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Arrange
|
||||
await wrapper.setProps({
|
||||
buttonLabel: "label text",
|
||||
});
|
||||
const paragraph = wrapper.find("p");
|
||||
|
||||
// Assert
|
||||
|
|
@ -39,6 +47,7 @@ describe("radio.vue", () => {
|
|||
// Arrange
|
||||
await wrapper.setProps({
|
||||
screenReaderOnlyText: "screenreader text",
|
||||
value: "test value",
|
||||
});
|
||||
const paragraph = wrapper.find(".sr-only");
|
||||
|
||||
|
|
@ -48,13 +57,10 @@ describe("radio.vue", () => {
|
|||
});
|
||||
|
||||
function setupMocks({ mountOptionsMockData = {} }) {
|
||||
const wrapper = mount(
|
||||
radio,
|
||||
getMountOptions({
|
||||
...mountOptionsMockData,
|
||||
mixins: [inputButtonWrapperMixin],
|
||||
})
|
||||
);
|
||||
const wrapper = mount(radio, {
|
||||
...mountOptionsMockData,
|
||||
mixins: [inputButtonWrapperMixin],
|
||||
});
|
||||
|
||||
return { wrapper };
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue