updated pattern for asynchronous testing. It should now fail the test if assertion in promise fails or if an error is thrown during the assertion.
This commit is contained in:
parent
6fe6628dec
commit
67f2707995
4 changed files with 67 additions and 25 deletions
|
|
@ -39,11 +39,17 @@ describe("vehicle-make.vue", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
apiPromise.finally(() => {
|
return apiPromise.finally(() => {
|
||||||
expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
try {
|
||||||
makeQuestionInitialData
|
expect(makeQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
||||||
);
|
makeQuestionInitialData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("BackButtonAction triggers a router.navigate change", async () => {
|
test("BackButtonAction triggers a router.navigate change", async () => {
|
||||||
|
|
@ -68,9 +74,15 @@ describe("vehicle-make.vue", () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
apiPromise.finally(() => {
|
return apiPromise.finally(() => {
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
try {
|
||||||
});
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Year set, arePagePrerequisitesValid should be true ", async () => {
|
test("Year set, arePagePrerequisitesValid should be true ", async () => {
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,23 @@ describe("vehicle-model.vue", () => {
|
||||||
undefined,
|
undefined,
|
||||||
(c) => c(wrapper.vm)
|
(c) => c(wrapper.vm)
|
||||||
);
|
);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
apiPromise.finally(() => {
|
return apiPromise.finally(() => {
|
||||||
expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
try {
|
||||||
modelQuestionInitialData
|
expect(modelQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
||||||
);
|
modelQuestionInitialData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("vehicle-model.vue", () => {
|
describe("vehicle-model.vue", () => {
|
||||||
test("BackButtonAction triggers a router.navigateWithoutSaving change", async () => {
|
test("BackButtonAction triggers a router.navigate change", async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
const { wrapper, apiPromise } = setupMocks({
|
const { wrapper, apiPromise } = setupMocks({
|
||||||
pageHeaderWidgetHeaderText: "Select a model to get started",
|
pageHeaderWidgetHeaderText: "Select a model to get started",
|
||||||
|
|
@ -65,12 +71,20 @@ describe("vehicle-model.vue", () => {
|
||||||
);
|
);
|
||||||
wrapper.vm.backButtonAction();
|
wrapper.vm.backButtonAction();
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
apiPromise.finally(() => {
|
return apiPromise.finally(() => {
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
try {
|
||||||
});
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("vehicle-model.vue", () => {
|
describe("vehicle-model.vue", () => {
|
||||||
test("Make set, arePagePrerequisitesValid should be true ", async () => {
|
test("Make set, arePagePrerequisitesValid should be true ", async () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,15 @@ describe("vehicle-style.vue", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
apiPromise.finally(() => {
|
return apiPromise.finally(() => {
|
||||||
expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
try {
|
||||||
styleQuestionInitialData
|
expect(styleQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
||||||
);
|
styleQuestionInitialData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -72,8 +77,13 @@ describe("vehicle-style.vue", () => {
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
apiPromise.finally(() => {
|
return apiPromise.finally(() => {
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
try {
|
||||||
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,17 @@ describe("vehicle-year.vue", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
apiPromise.finally(() => {
|
return apiPromise.finally(() => {
|
||||||
expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
try {
|
||||||
yearQuestionInitialData
|
expect(yearQuestion.methods.initializeComponent).toHaveBeenCalledWith(
|
||||||
);
|
yearQuestionInitialData
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
throw e
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue