57 lines
No EOL
1.7 KiB
JavaScript
57 lines
No EOL
1.7 KiB
JavaScript
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
|
import { shallowMount } from "@vue/test-utils";
|
|
import { setupMocksForJsFiles, getMountOptions } from "@/helpers/unit-test-helper.js";
|
|
import { storeActions } from "@/constants/store-actions";
|
|
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
|
import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin";
|
|
|
|
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
|
|
navigateForward: jest.fn()
|
|
}));
|
|
|
|
describe("vin-pages-mixin", () => {
|
|
afterEach(() => {
|
|
jest.clearAllMocks();
|
|
})
|
|
|
|
describe("navigateForwardWithSingleCarMatch", () => {
|
|
test("should navigateForward", async () => {
|
|
// Arrange
|
|
const { wrapper } = setupMocks({});
|
|
vehicleQuestionsMixin.methods.navigateForward = jest.fn();
|
|
|
|
// Act
|
|
await wrapper.vm.navigateForwardWithSingleCarMatch();
|
|
|
|
// Assert
|
|
expect(vehicleQuestionsMixin.methods.navigateForward).toHaveBeenCalled();
|
|
})
|
|
});
|
|
});
|
|
|
|
function setupMocks({ partsOrQuestions = [] }) {
|
|
const baseMixin = setupMocksForJsFiles({
|
|
actionList: [
|
|
{
|
|
actionName: storeActions.GET_PARTS_OR_QUESTIONS,
|
|
data: {
|
|
partsOrQuestions: partsOrQuestions
|
|
}
|
|
},
|
|
],
|
|
});
|
|
|
|
const mocks = getMountOptions({});
|
|
|
|
const mockVinComponent = {
|
|
components: { loadingModal },
|
|
template: '<loadingModal ref="loadingModal" />',
|
|
mixins: [vinPagesMixin, baseMixin.baseMixin]
|
|
};
|
|
|
|
const wrapper = shallowMount(mockVinComponent, mocks);
|
|
|
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
|
|
|
return { wrapper };
|
|
} |