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