Skip to content

Commit

Permalink
fix: adds another test
Browse files Browse the repository at this point in the history
  • Loading branch information
FritzHoing committed Jan 10, 2025
1 parent 3ddd0fe commit eac8c00
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/service/ApplicationService/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,25 @@ describe('ApplicationService', () => {
}));
});

it('should return the application when the fetch is successful', async () => {
const mockApplication = { id: 123, name: 'TestApp' } as Application;

(fetch as jest.Mock).mockResolvedValueOnce({
ok: true,
json: jest.fn().mockResolvedValueOnce(mockApplication),
});

const result = await service.findOneByName('TestApp');

expect(fetch).toHaveBeenCalledWith('/applications/name/TestApp', expect.objectContaining({
method: 'GET',
headers: expect.any(Object),
}));

expect(result).toEqual(mockApplication);
expect(result.name).toBe('TestApp');
});

it('is defined', () => {
expect(ApplicationService).toBeDefined();
});
Expand Down

0 comments on commit eac8c00

Please sign in to comment.