65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
// Components
|
|
import customerDetails from "@/layouts/payment-method/payment-method.vue";
|
|
|
|
// Supporting Files
|
|
import { shallowMount } from "@vue/test-utils";
|
|
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
|
import store from "@/store";
|
|
|
|
// Mock our module for promises.
|
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
|
settleAllPromises: jest.fn(),
|
|
}));
|
|
|
|
jest.mock("@/helpers/heritage-integration/order-helper.js", () => ({
|
|
submitWorkOrder: jest.fn(),
|
|
}));
|
|
|
|
describe("payment-method.vue", () => {
|
|
describe("navigation", () => {
|
|
test("if the back button is clicked, navigate back", async () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks();
|
|
|
|
// Act
|
|
await wrapper.vm.backButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
|
});
|
|
|
|
test("if the continue button is clicked, navigate forward", async () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks();
|
|
|
|
// Act
|
|
await wrapper.vm.forwardButtonAction();
|
|
|
|
// Assert
|
|
expect(wrapper.vm.$router.navigateWithoutSaving).toHaveBeenCalled();
|
|
});
|
|
});
|
|
});
|
|
|
|
function setupMocks() {
|
|
store.getters = {
|
|
damage: {},
|
|
lineItems: [],
|
|
};
|
|
|
|
const wrapper = shallowMount(
|
|
customerDetails,
|
|
getMountOptions({
|
|
router: {
|
|
navigate: jest.fn(),
|
|
navigateWithSaving: jest.fn(),
|
|
navigateWithoutSaving: jest.fn(),
|
|
},
|
|
store: {
|
|
getters: store.getters,
|
|
},
|
|
})
|
|
);
|
|
|
|
return { wrapper };
|
|
}
|