Add remaining tests

This commit is contained in:
Chloe Herd 2023-03-15 09:38:58 -04:00
parent 3543c1cb04
commit 78160d4cff
3 changed files with 32 additions and 36 deletions

View file

@ -200,21 +200,19 @@ describe("textboxQuestion.vue", () => {
it("Should call this.handleChange when image is submitted with valid value.", async () => {
// Arrange
const inputId = 'test';
const responseValue = 'testResponse';
const inputId = "test";
const responseValue = "testResponse";
const storeMixin = {
methods: {
dispatchStoreAction: jest.fn().mockImplementation(() => {
return new Promise(
(resolve, reject) => resolve(
{
data: [ responseValue ]
}
)
return new Promise((resolve, reject) =>
resolve({
data: [responseValue],
})
);
})
}
}),
},
};
const wrapper = shallowMount(textboxQuestion, {
@ -229,7 +227,7 @@ describe("textboxQuestion.vue", () => {
inputId: inputId,
},
mixins: [mockMixin, storeMixin],
attachTo: document.body
attachTo: document.body,
});
wrapper.vm.handleChange = jest.fn().mockImplementation(() => {});
@ -237,7 +235,7 @@ describe("textboxQuestion.vue", () => {
// Act
const imageUploadField = wrapper.find('[data-test="image-upload"]');
await imageUploadField.trigger('change');
await imageUploadField.trigger("change");
await wrapper.vm.$nextTick();
@ -249,20 +247,18 @@ describe("textboxQuestion.vue", () => {
it("Should emit image-lookup-error when image is submitted with invalid value", async () => {
// Arrange
const inputId = 'test';
const inputId = "test";
const storeMixin = {
methods: {
dispatchStoreAction: jest.fn().mockImplementation(() => {
return new Promise(
(resolve, reject) => resolve(
{
data: []
}
)
return new Promise((resolve, reject) =>
resolve({
data: [],
})
);
})
}
}),
},
};
const wrapper = shallowMount(textboxQuestion, {
@ -277,7 +273,7 @@ describe("textboxQuestion.vue", () => {
inputId: inputId,
},
mixins: [mockMixin, storeMixin],
attachTo: document.body
attachTo: document.body,
});
wrapper.vm.handleChange = jest.fn().mockImplementation(() => {});
@ -285,7 +281,7 @@ describe("textboxQuestion.vue", () => {
// Act
const imageUploadField = wrapper.find('[data-test="image-upload"]');
await imageUploadField.trigger('change');
await imageUploadField.trigger("change");
await wrapper.vm.$nextTick();
@ -296,16 +292,14 @@ describe("textboxQuestion.vue", () => {
it("Should emit image-lookup-error when image endpoint responds with an error", async () => {
// Arrange
const inputId = 'test';
const inputId = "test";
const storeMixin = {
methods: {
dispatchStoreAction: jest.fn().mockImplementation(() => {
return new Promise(
(resolve, reject) => reject()
);
})
}
return new Promise((resolve, reject) => reject());
}),
},
};
const wrapper = shallowMount(textboxQuestion, {
@ -320,7 +314,7 @@ describe("textboxQuestion.vue", () => {
inputId: inputId,
},
mixins: [mockMixin, storeMixin],
attachTo: document.body
attachTo: document.body,
});
wrapper.vm.handleChange = jest.fn().mockImplementation(() => {});
@ -328,7 +322,7 @@ describe("textboxQuestion.vue", () => {
// Act
const imageUploadField = wrapper.find('[data-test="image-upload"]');
await imageUploadField.trigger('change');
await imageUploadField.trigger("change");
await wrapper.vm.$nextTick();

View file

@ -246,10 +246,10 @@ describe("vin-lookup.vue", () => {
test("Error emitted by textbox-question element => VinScanFailed alert shown.", async () => {
// Arrange
const { wrapper } = setupMocks({});
// Act
const vinLookup = wrapper.findComponent('[data-test="vin-lookup-component"]');
vinLookup.trigger('imageLookupError');
vinLookup.trigger("imageLookupError");
await wrapper.vm.$nextTick();
// Assert

View file

@ -409,14 +409,14 @@ describe("Actions", () => {
const dummyImage = {};
globalMethods.callHttpClient.mockImplementation(() => {
return Promise.resolve({ data: [ "1C6JJTAG3NL134044" ] });
return Promise.resolve({ data: ["1C6JJTAG3NL134044"] });
});
// Act
const response = await actions.lookupVinByImage(context, dummyImage);
// Assert
expect(response.data).toEqual([ "1C6JJTAG3NL134044" ]);
expect(response.data).toEqual(["1C6JJTAG3NL134044"]);
});
it("lookupVinByImage action, should reject if error in calling API", async () => {
@ -431,7 +431,9 @@ describe("Actions", () => {
// Act
// Assert
await expect(actions.lookupVinByImage(context, dummyImage)).rejects.toEqual("An error occurred");
await expect(actions.lookupVinByImage(context, dummyImage)).rejects.toEqual(
"An error occurred"
);
});
it("getVehicleMakes action, should return makes list", async () => {