Skip to content

Commit

Permalink
10492: fix api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pixiwyn committed Oct 4, 2024
1 parent 78e0cf3 commit 485c741
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import '@web-api/persistence/postgres/userCaseNotes/mocks.jest';
import { MOCK_CASE } from '../../../../../shared/src/test/mockCase';
import { UnauthorizedError } from '@web-api/errors/errors';
import { UnknownAuthUser } from '@shared/business/entities/authUser/AuthUser';
import { UserCaseNote } from '@shared/business/entities/notes/UserCaseNote';
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
import { getUserCaseNoteForCasesInteractor } from './getUserCaseNoteForCasesInteractor';
import { getUserCaseNoteForCases as getUserCaseNoteForCasesMock } from '@web-api/persistence/postgres/userCaseNotes/getUserCaseNoteForCases';
import { mockJudgeUser } from '@shared/test/mockAuthUsers';
import { omit } from 'lodash';

Expand All @@ -22,15 +24,15 @@ describe('getUserCaseNoteForCasesInteractor', () => {
section: 'colvinChambers',
} as UnknownAuthUser;

const getUserCaseNoteForCases = getUserCaseNoteForCasesMock as jest.Mock;

beforeEach(() => {
mockCurrentUser = mockJudge;
mockNote = MOCK_NOTE;
applicationContext
.getPersistenceGateway()
.getUserById.mockImplementation(() => mockCurrentUser);
applicationContext
.getPersistenceGateway()
.getUserCaseNoteForCases.mockResolvedValue([mockNote]);
getUserCaseNoteForCases.mockResolvedValue([new UserCaseNote(mockNote)]);
applicationContext
.getUseCaseHelpers()
.getJudgeInSectionHelper.mockReturnValue(mockJudge);
Expand All @@ -53,9 +55,9 @@ describe('getUserCaseNoteForCasesInteractor', () => {
});

it('throws an error if the entity returned from persistence is invalid', async () => {
applicationContext
.getPersistenceGateway()
.getUserCaseNoteForCases.mockResolvedValue([omit(MOCK_NOTE, 'userId')]);
getUserCaseNoteForCases.mockResolvedValue([
new UserCaseNote([omit(MOCK_NOTE, 'userId')]),
]);

await expect(
getUserCaseNoteForCasesInteractor(
Expand Down Expand Up @@ -101,9 +103,8 @@ describe('getUserCaseNoteForCasesInteractor', () => {
omit(mockUser, 'section'),
);

expect(
applicationContext.getPersistenceGateway().getUserCaseNoteForCases.mock
.calls[0][0].userId,
).toEqual(userIdToExpect);
expect(getUserCaseNoteForCases.mock.calls[0][0].userId).toEqual(
userIdToExpect,
);
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import '@web-api/persistence/postgres/messages/mocks.jest';
import '@web-api/persistence/postgres/userCaseNotes/mocks.jest';
import { applicationContext } from '../../../../../shared/src/business/test/createTestApplicationContext';
import { processUserCaseNoteEntries } from '@web-api/business/useCases/processStreamRecords/processUserCaseNoteEntries';
import { upsertUserCaseNotes } from '@web-api/persistence/postgres/userCaseNotes/upsertUserCaseNotes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,5 @@ export const getMessagesByDocketNumber = async ({
.execute(),
);

console.log('*** messages', messages);

return messages.map(message => messageResultEntity(message));
};

0 comments on commit 485c741

Please sign in to comment.