Fixing test

This commit is contained in:
Michaela Brydon 2024-07-01 14:33:05 -04:00
parent 8e9245b37f
commit 7e3ded3dca

View file

@ -8,11 +8,10 @@ import { useMainStore } from '@/store';
import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin'; import vehicleQuestionsMixin from '@/mixins/vehicle-questions-mixin';
import { nextTick } from 'vue'; import { nextTick } from 'vue';
import baseMixin from '@/mixins/base-mixin'; import baseMixin from '@/mixins/base-mixin';
import settleAllPromises from '@/helpers/layout-helper.js';
// Mock our module for promises. // Mock our module for promises.
jest.mock('@/helpers/layout-helper.js', () => ({ jest.mock('@/helpers/layout-helper.js', () => jest.fn());
settleAllPromises: jest.fn()
}));
// Mock fetchCmsContentForPage // Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({ jest.mock('@/helpers/cms-content-helper', () => ({
@ -244,6 +243,7 @@ describe('capabilityQuestions.vue', () => {
}); });
describe('forwardButtonAction', () => { describe('forwardButtonAction', () => {
settleAllPromises.mockImplementation(() => []);
test('Should clear out answerData', async () => { test('Should clear out answerData', async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -312,7 +312,7 @@ describe('capabilityQuestions.vue', () => {
wrapper.unmount(); wrapper.unmount();
}); });
test('Should call getPartFromCapabilityQuestionAnswer', async () => { test('Should call updatePartFromCapabilityQuestionAnswer', async () => {
// Arrange // Arrange
const { wrapper } = setupMocks({}); const { wrapper } = setupMocks({});
@ -337,14 +337,14 @@ describe('capabilityQuestions.vue', () => {
partsOrQuestions: [] partsOrQuestions: []
} }
})); }));
const getPartFromCapabilityQuestionAnswerSpy = jest.spyOn(useMainStore(), 'getPartFromCapabilityQuestionAnswer'); const updatePartFromCapabilityQuestionAnswerSpy = jest.spyOn(useMainStore(), 'updatePartFromCapabilityQuestionAnswer');
getPartFromCapabilityQuestionAnswerSpy.mockClear(); updatePartFromCapabilityQuestionAnswerSpy.mockClear();
// Act // Act
await wrapper.vm.forwardButtonAction(); await wrapper.vm.forwardButtonAction();
// Assert // Assert
expect(getPartFromCapabilityQuestionAnswerSpy).toHaveBeenCalledTimes(1); expect(updatePartFromCapabilityQuestionAnswerSpy).toHaveBeenCalledTimes(1);
wrapper.unmount(); wrapper.unmount();
}); });