unit test to check page prereqs

This commit is contained in:
Kroell 2023-01-06 14:22:54 -05:00
parent 9bac32b093
commit 9be65c0c81
2 changed files with 21 additions and 43 deletions

View file

@ -32,30 +32,23 @@ jest.mock("@/helpers/damage-helper", () => ({
}));
describe("license-plate-lookup.vue", () => {
describe("navigation", () => {
test("backButtonAction triggers a router.navigate change", async () => {
//Arrange
const { wrapper } = setupMocks({});
test("Make set, arePagePrerequisitesValid should be true ", () => {
//Arrange
const { wrapper } = setupMocks({});
useMainStore().order.vehicle.carId = "CR00000395";
//Act
licensePlateLookup.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: "license-plate-lookup" } },
undefined,
(c) => c(wrapper.vm)
);
wrapper.vm.backButtonAction();
//Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
});
// TODO: Test - Continue button should call forwardButtonAction when data entered matches data from store
// TODO: Test - Methods to get values from the store (license plate, registration zip)
//Act
licensePlateLookup.beforeRouteEnter.call(
wrapper.vm,
{ query: { issPage: "license-plate-lookup" } },
undefined,
(c) => c(wrapper.vm)
);
let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
//Assert
expect(arePagePrerequisitesValid).toBe(true);
});
});
@ -63,13 +56,13 @@ function setupMocks({
licensePlateQuestionCmsContent = {},
licensePlateQuestionInitialData = {},
pageHeaderWidgetHeaderText = {},
pageFooterWidgetCmsContent = {},
mountOptionsMockData = {},
partsOrQuestions = [],
//Values to set in the state store
carId = null,
registrationZipCode = null,
licensePlate = null, //"TESTPLATE",
emailAddress = null, //"test@test.com",
}) {
//Mock api responses
const apiResponses = {
@ -84,6 +77,8 @@ function setupMocks({
LogoImage:
"https://digitalisscms.dev.safelite.io/images/default-source/default-album/logos/insuranceLogo.jpg",
},
SiteFooterWidget: pageFooterWidgetCmsContent,
},
licensePlateQuestionInitialData: licensePlateQuestionInitialData,
};

View file

@ -20,8 +20,7 @@
@back-clicked="backButtonAction"
@forward-clicked="forwardButtonAction"
ref="siteFooter"
:is-forward-action-disabled="!meta.valid" />
<!--:is-forward-action-disabled="!meta.valid"-->
:is-forward-action-disabled="isForwardActionDisabled" />
</div>
</div>
</Form>
@ -52,30 +51,14 @@ export default {
name: 'license-plate-lookup',
mixins: [BaseFormMixin],
components: {
<<<<<<< HEAD
VeeValidateForm: Form,
Form,
siteFooter,
siteHeader,
siteSubHeader,
vehicleBanner,
textboxQuestion,
LicensePlateQuestion,
<<<<<<< HEAD
ZipQuestion,
LicensePlateLookupAlerts,
},
setup() {
const mainStore = useMainStore();
=======
ZipQuestion,
=======
Form,
SiteFooter,
SiteHeader,
SiteSubHeader,
VehicleBanner,
>>>>>>> c55f3731be77a48139e06899a0ce08cb157b91fd
>>>>>>> develop
},
data() {
return {
@ -108,7 +91,7 @@ export default {
});
},
methods: {
arePagePrerequisiteValid() {
arePagePrerequisitesValid() {
if (this.mainStore.order.vehicle.carId) {
return true;
}