resolve todos in website
This commit is contained in:
35
core/identity/application/use-cases/StartAuthUseCase.test.ts
Normal file
35
core/identity/application/use-cases/StartAuthUseCase.test.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { describe, it, expect, vi, type Mock } from 'vitest';
|
||||
import { StartAuthUseCase } from './StartAuthUseCase';
|
||||
import type { IdentityProviderPort } from '../ports/IdentityProviderPort';
|
||||
import type { StartAuthCommandDTO } from '../dto/StartAuthCommandDTO';
|
||||
|
||||
describe('StartAuthUseCase', () => {
|
||||
let provider: {
|
||||
startAuth: Mock;
|
||||
};
|
||||
let useCase: StartAuthUseCase;
|
||||
|
||||
beforeEach(() => {
|
||||
provider = {
|
||||
startAuth: vi.fn(),
|
||||
};
|
||||
|
||||
useCase = new StartAuthUseCase(provider as unknown as IdentityProviderPort);
|
||||
});
|
||||
|
||||
it('delegates to the identity provider to start auth', async () => {
|
||||
const command: StartAuthCommandDTO = {
|
||||
redirectUri: 'https://app/callback',
|
||||
provider: 'demo',
|
||||
};
|
||||
|
||||
const expected = { redirectUrl: 'https://auth/redirect', state: 'state-123' };
|
||||
|
||||
provider.startAuth.mockResolvedValue(expected);
|
||||
|
||||
const result = await useCase.execute(command);
|
||||
|
||||
expect(provider.startAuth).toHaveBeenCalledWith(command);
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user