Skip to content

Commit

Permalink
test: fix bug in logging assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
Codex- committed Oct 27, 2024
1 parent d587c66 commit e2c1b11
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/return-dispatch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,7 +674,7 @@ describe("return-dispatch", () => {
expect(apiRetryOrTimeoutMock).toHaveBeenCalledOnce();
await vi.advanceTimersByTimeAsync(1); // deplete queue

assertOnlyCalled(coreDebugLogMock, coreInfoLogMock);
assertOnlyCalled(coreInfoLogMock);

expect(coreInfoLogMock).toHaveBeenCalledOnce();
expect(coreInfoLogMock.mock.calls[0]?.[0]).toMatchSnapshot();
Expand Down
8 changes: 5 additions & 3 deletions src/test-utils/logging.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,13 @@ function assertOnlyCalledInner(
// Once Node 22 is LTS, this can be:
// const diff = coreLogMockSet.symmetricDifference(new Set(coreLogMocks));

const diff = symDiff([[...coreLogMockSet], coreLogMocks]);

for (const logMock of diff) {
const notCalled = symDiff([[...coreLogMockSet], coreLogMocks]);
for (const logMock of notCalled) {
expect(logMock).not.toHaveBeenCalled();
}
for (const logMock of coreLogMocks) {
expect(logMock).toHaveBeenCalled();
}
}

function assertNoneCalledInner(
Expand Down

0 comments on commit e2c1b11

Please sign in to comment.