seed data
This commit is contained in:
@@ -80,7 +80,7 @@ describe('AuthController', () => {
|
||||
});
|
||||
|
||||
describe('getSession', () => {
|
||||
it('should call service.getCurrentSession and return session DTO', async () => {
|
||||
it('should call service.getCurrentSession and write JSON response', async () => {
|
||||
const session: AuthSessionDTO = {
|
||||
token: 'token123',
|
||||
user: {
|
||||
@@ -91,18 +91,23 @@ describe('AuthController', () => {
|
||||
};
|
||||
(service.getCurrentSession as Mock).mockResolvedValue(session);
|
||||
|
||||
const result = await controller.getSession();
|
||||
const res = { json: vi.fn() } as any;
|
||||
|
||||
await controller.getSession(res);
|
||||
|
||||
expect(service.getCurrentSession).toHaveBeenCalled();
|
||||
expect(result).toEqual(session);
|
||||
expect(res.json).toHaveBeenCalledWith(session);
|
||||
});
|
||||
|
||||
it('should return null if no session', async () => {
|
||||
it('should write JSON null when no session', async () => {
|
||||
(service.getCurrentSession as Mock).mockResolvedValue(null);
|
||||
|
||||
const result = await controller.getSession();
|
||||
const res = { json: vi.fn() } as any;
|
||||
|
||||
expect(result).toBeNull();
|
||||
await controller.getSession(res);
|
||||
|
||||
expect(service.getCurrentSession).toHaveBeenCalled();
|
||||
expect(res.json).toHaveBeenCalledWith(null);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user