fix issues in core
This commit is contained in:
@@ -2,6 +2,7 @@ import { describe, it, expect, vi, type Mock } from 'vitest';
|
||||
import { GetCurrentUserSessionUseCase } from './GetCurrentUserSessionUseCase';
|
||||
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import type { AuthSessionDTO } from '../dto/AuthSessionDTO';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
|
||||
describe('GetCurrentUserSessionUseCase', () => {
|
||||
let sessionPort: {
|
||||
@@ -9,7 +10,8 @@ describe('GetCurrentUserSessionUseCase', () => {
|
||||
createSession: Mock;
|
||||
clearSession: Mock;
|
||||
};
|
||||
|
||||
let logger: Logger;
|
||||
let output: UseCaseOutputPort<any> & { present: Mock };
|
||||
let useCase: GetCurrentUserSessionUseCase;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -19,7 +21,22 @@ describe('GetCurrentUserSessionUseCase', () => {
|
||||
clearSession: vi.fn(),
|
||||
};
|
||||
|
||||
useCase = new GetCurrentUserSessionUseCase(sessionPort as unknown as IdentitySessionPort);
|
||||
logger = {
|
||||
debug: vi.fn(),
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
} as unknown as Logger;
|
||||
|
||||
output = {
|
||||
present: vi.fn(),
|
||||
};
|
||||
|
||||
useCase = new GetCurrentUserSessionUseCase(
|
||||
sessionPort as unknown as IdentitySessionPort,
|
||||
logger,
|
||||
output,
|
||||
);
|
||||
});
|
||||
|
||||
it('returns the current auth session when one exists', async () => {
|
||||
@@ -40,7 +57,8 @@ describe('GetCurrentUserSessionUseCase', () => {
|
||||
const result = await useCase.execute();
|
||||
|
||||
expect(sessionPort.getCurrentSession).toHaveBeenCalledTimes(1);
|
||||
expect(result).toEqual(session);
|
||||
expect(result.isOk()).toBe(true);
|
||||
expect(output.present).toHaveBeenCalledWith(session);
|
||||
});
|
||||
|
||||
it('returns null when there is no active session', async () => {
|
||||
@@ -49,6 +67,7 @@ describe('GetCurrentUserSessionUseCase', () => {
|
||||
const result = await useCase.execute();
|
||||
|
||||
expect(sessionPort.getCurrentSession).toHaveBeenCalledTimes(1);
|
||||
expect(result).toBeNull();
|
||||
expect(result.isOk()).toBe(true);
|
||||
expect(output.present).toHaveBeenCalledWith(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user