Merge pull request #30 from Safelite/feature/Digital/SSR-100

updated pattern for asynchronous testing.  It should now fail the tes…
This commit is contained in:
Kulbhushan Kaushik 2022-11-03 13:13:02 -04:00 committed by GitHub
commit 22f051d182
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 67 additions and 25 deletions

View file

@ -39,11 +39,17 @@ describe("vehicle-make.vue", () => {
);
//Assert
apiPromise.finally(() => {
expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith(
makeQuestionInitialData
);
return apiPromise.finally(() => {
try {
expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith(
makeQuestionInitialData
);
}
catch (e) {
throw e
}
});
});
test("BackButtonAction triggers a router.navigate change", async () => {
@ -68,9 +74,15 @@ describe("vehicle-make.vue", () => {
await nextTick();
//Assert
apiPromise.finally(() => {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
});
return apiPromise.finally(() => {
try {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
}
catch (e) {
throw e
}
});
});
test("Year set, arePagePrerequisitesValid should be true ", async () => {

View file

@ -36,17 +36,23 @@ describe("vehicle-model.vue", () => {
undefined,
(c) => c(wrapper.vm)
);
//Assert
apiPromise.finally(() => {
expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith(
modelQuestionInitialData
);
return apiPromise.finally(() => {
try {
expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith(
modelQuestionInitialData
);
}
catch (e) {
throw e
}
});
});
});
describe("vehicle-model.vue", () => {
test("BackButtonAction triggers a router.navigateWithoutSaving change", async () => {
test("BackButtonAction triggers a router.navigate change", async () => {
//Arrange
const { wrapper, apiPromise } = setupMocks({
pageHeaderWidgetHeaderText: "Select a model to get started",
@ -65,12 +71,20 @@ describe("vehicle-model.vue", () => {
);
wrapper.vm.backButtonAction();
await nextTick();
//Assert
apiPromise.finally(() => {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
});
return apiPromise.finally(() => {
try {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
}
catch (e) {
throw e
}
});
});
});
describe("vehicle-model.vue", () => {
test("Make set, arePagePrerequisitesValid should be true ", async () => {
//Arrange

View file

@ -43,10 +43,15 @@ describe("vehicle-style.vue", () => {
);
//Assert
apiPromise.finally(() => {
expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith(
styleQuestionInitialData
);
return apiPromise.finally(() => {
try {
expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith(
styleQuestionInitialData
);
}
catch (e) {
throw e
}
});
});
@ -72,8 +77,13 @@ describe("vehicle-style.vue", () => {
await nextTick();
//Assert
apiPromise.finally(() => {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
return apiPromise.finally(() => {
try {
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
}
catch (e) {
throw e
}
});
});

View file

@ -36,11 +36,17 @@ describe("vehicle-year.vue", () => {
);
//Assert
apiPromise.finally(() => {
expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith(
yearQuestionInitialData
);
return apiPromise.finally(() => {
try {
expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith(
yearQuestionInitialData
);
}
catch (e) {
throw e
}
});
});
});