feat(tests): update test configurations and improve mocking setup

This commit is contained in:
Jose Selesan
2026-06-03 09:35:04 -03:00
parent c1b47674c8
commit 473686528e
8 changed files with 27 additions and 19 deletions

View File

@@ -1,14 +1,15 @@
import { beforeEach, expect, mock, test } from 'bun:test';
import { beforeEach, expect, test } from 'bun:test';
import {
ComplexMembersError,
inviteComplexUser,
} from '@/modules/complex/services/complex-members.service';
import { prismaMock, sendMailMock, transactionMock } from '../support/prisma.mock';
const { ComplexMembersError, inviteComplexUser } = await import(
'@/modules/complex/services/complex-members.service'
);
beforeEach(() => {
prismaMock._reset();
mock.clearAllMocks();
sendMailMock.mockClear();
transactionMock.mockClear();
});
test('creates a pending invitation and sends the email', async () => {
@@ -21,10 +22,10 @@ test('creates a pending invitation and sends the email', async () => {
complexId: 'complex-1',
email: 'new.member@example.com',
tokenHash: 'token-hash',
expiresAt: new Date('2026-04-29T00:00:00.000Z'),
expiresAt: new Date('2027-01-01T00:00:00.000Z'),
acceptedAt: null,
revokedAt: null,
createdAt: new Date('2026-04-22T00:00:00.000Z'),
createdAt: new Date('2026-12-01T00:00:00.000Z'),
} as never);
const result = await inviteComplexUser('admin-1', 'complex-1', {