260323:0954 fix CI : Run Tests frontend #01
CI / CD Pipeline / build (push) Failing after 15m27s
CI / CD Pipeline / release (push) Has been skipped
CI / CD Pipeline / deploy (push) Has been skipped

This commit is contained in:
admin
2026-03-23 09:54:31 +07:00
parent 4422c68894
commit 32141f519a
8 changed files with 563 additions and 1073 deletions
@@ -34,24 +34,16 @@ describe('projectService', () => {
});
});
describe('getById', () => {
it('should call GET /projects/:id', async () => {
const mockResponse = { id: 1, name: 'Project Alpha', code: 'P-001' };
describe('getByUuid', () => {
it('should call GET /projects/:uuid', async () => {
const mockResponse = { id: 1, uuid: 'uuid-1', name: 'Project Alpha', code: 'P-001' };
vi.mocked(apiClient.get).mockResolvedValue({ data: mockResponse });
const result = await projectService.getById(1);
const result = await projectService.getByUuid('uuid-1');
expect(apiClient.get).toHaveBeenCalledWith('/projects/1');
expect(apiClient.get).toHaveBeenCalledWith('/projects/uuid-1');
expect(result).toEqual(mockResponse);
});
it('should work with string id', async () => {
vi.mocked(apiClient.get).mockResolvedValue({ data: {} });
await projectService.getById('123');
expect(apiClient.get).toHaveBeenCalledWith('/projects/123');
});
});
describe('create', () => {
@@ -68,25 +60,25 @@ describe('projectService', () => {
});
describe('update', () => {
it('should call PUT /projects/:id with data', async () => {
it('should call PUT /projects/:uuid with data', async () => {
const updateData = { projectName: 'Updated Project' };
const mockResponse = { id: 1, projectName: 'Updated Project' };
const mockResponse = { id: 1, uuid: 'uuid-1', projectName: 'Updated Project' };
vi.mocked(apiClient.put).mockResolvedValue({ data: mockResponse });
const result = await projectService.update(1, updateData);
const result = await projectService.update('uuid-1', updateData);
expect(apiClient.put).toHaveBeenCalledWith('/projects/1', updateData);
expect(apiClient.put).toHaveBeenCalledWith('/projects/uuid-1', updateData);
expect(result).toEqual(mockResponse);
});
});
describe('delete', () => {
it('should call DELETE /projects/:id', async () => {
it('should call DELETE /projects/:uuid', async () => {
vi.mocked(apiClient.delete).mockResolvedValue({ data: {} });
const result = await projectService.delete(1);
const result = await projectService.delete('uuid-1');
expect(apiClient.delete).toHaveBeenCalledWith('/projects/1');
expect(apiClient.delete).toHaveBeenCalledWith('/projects/uuid-1');
expect(result).toEqual({});
});
});