diff --git a/src/common-components/loading-modal/loading-modal.spec.js b/src/common-components/loading-modal/loading-modal.spec.js new file mode 100644 index 000000000..7a500ce73 --- /dev/null +++ b/src/common-components/loading-modal/loading-modal.spec.js @@ -0,0 +1,47 @@ +import { shallowMount } from "@vue/test-utils"; +import loadingModal from "./loading-modal"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import store from "@/store"; + +jest.mock( + "@/store", + () => { + return {}; + }, + { virtual: true } +); + +jest.mock('@/assets/img/loader.gif', () => 'loader.gif') +jest.mock('@/assets/img/windshield.png', () => 'windshield.png') + +describe("loadingModal", () => { + test("showModal sets modal visible", async () => { + // Arrange + const { wrapper } = setupMocks(); + wrapper.vm.isModalVisible = false; + + //Act + wrapper.vm.showModal(); + + // Assert + expect(wrapper.vm.isModalVisible).toEqual(true); + wrapper.unmount(); + }); +}); + + +function setupMocks() { + + //Mock store + store.dispatch = jest.fn(() => {}); + store.getters = { }; + const mountOptions = getMountOptions({ + store: { + dispatch: store.dispatch, + getters: store.getters, + }, + }); + + const wrapper = shallowMount(loadingModal, mountOptions); + return { wrapper }; +} \ No newline at end of file diff --git a/src/common-components/loading-modal/loading-modal.vue b/src/common-components/loading-modal/loading-modal.vue index 4f1365802..bcdb4454c 100644 --- a/src/common-components/loading-modal/loading-modal.vue +++ b/src/common-components/loading-modal/loading-modal.vue @@ -1,21 +1,16 @@