website refactor
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { describe, it, expect, vi } from 'vitest';
|
||||
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
||||
import { TeamJoinService } from './TeamJoinService';
|
||||
import type { TeamsApiClient } from '@/lib/api/teams/TeamsApiClient';
|
||||
|
||||
@@ -44,10 +44,12 @@ describe('TeamJoinService', () => {
|
||||
const result = await service.getJoinRequests('team-1', 'user-1', true);
|
||||
|
||||
expect(mockApiClient.getJoinRequests).toHaveBeenCalledWith('team-1');
|
||||
expect(result).toHaveLength(2);
|
||||
expect(result.isOk()).toBe(true);
|
||||
const viewModels = result.unwrap();
|
||||
expect(viewModels).toHaveLength(2);
|
||||
|
||||
const first = result[0];
|
||||
const second = result[1];
|
||||
const first = viewModels[0];
|
||||
const second = viewModels[1];
|
||||
|
||||
expect(first).toBeDefined();
|
||||
expect(second).toBeDefined();
|
||||
@@ -77,20 +79,26 @@ describe('TeamJoinService', () => {
|
||||
|
||||
const result = await service.getJoinRequests('team-1', 'user-1', false);
|
||||
|
||||
expect(result[0]).toBeDefined();
|
||||
expect(result[0]!.canApprove).toBe(false);
|
||||
expect(result.isOk()).toBe(true);
|
||||
const viewModels = result.unwrap();
|
||||
expect(viewModels[0]).toBeDefined();
|
||||
expect(viewModels[0]!.canApprove).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('approveJoinRequest', () => {
|
||||
it('should throw not implemented error', async () => {
|
||||
await expect(service.approveJoinRequest()).rejects.toThrow('Not implemented: API endpoint for approving join requests');
|
||||
const result = await service.approveJoinRequest();
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.getError().message).toBe('Not implemented: API endpoint for approving join requests');
|
||||
});
|
||||
});
|
||||
|
||||
describe('rejectJoinRequest', () => {
|
||||
it('should throw not implemented error', async () => {
|
||||
await expect(service.rejectJoinRequest()).rejects.toThrow('Not implemented: API endpoint for rejecting join requests');
|
||||
const result = await service.rejectJoinRequest();
|
||||
expect(result.isErr()).toBe(true);
|
||||
expect(result.getError().message).toBe('Not implemented: API endpoint for rejecting join requests');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user