Skip to content

Commit

Permalink
fixed Cannot find name global
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavangbhat committed Mar 5, 2024
1 parent 030fe81 commit 3d5295d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/tests/services/rdsBackendService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('rdsBackendService', () => {
});

it('should make a successful API call and return the expected data', async () => {
jest.spyOn(global, 'fetch').mockResolvedValueOnce({
jest.spyOn(globalThis as any, 'fetch').mockResolvedValueOnce({
ok: true,
status: 200,
json: jest.fn().mockResolvedValueOnce({ ...missedUpdatesUsersResponse, data: missedUpdatesUsersMock }),
Expand All @@ -32,7 +32,7 @@ describe('rdsBackendService', () => {
expect(result).toEqual({ ...missedUpdatesUsersMock });
});
it('should make a successful API call with cursor', async () => {
jest.spyOn(global, 'fetch').mockResolvedValueOnce({
jest.spyOn(globalThis as any, 'fetch').mockResolvedValueOnce({
ok: true,
status: 200,
json: jest.fn().mockResolvedValueOnce({ ...missedUpdatesUsersResponse, data: missedUpdatesUsersMock }),
Expand All @@ -51,7 +51,7 @@ describe('rdsBackendService', () => {
expect(result).toEqual({ ...missedUpdatesUsersMock });
});
it('should throw error when api call fails', async () => {
jest.spyOn(global, 'fetch').mockResolvedValueOnce({
jest.spyOn(globalThis as any, 'fetch').mockResolvedValueOnce({
ok: false,
status: 400,
} as unknown as Response);
Expand All @@ -60,7 +60,7 @@ describe('rdsBackendService', () => {

it('should handle unknown errors', async () => {
const consoleSpy = jest.spyOn(console, 'error');
jest.spyOn(global, 'fetch').mockRejectedValueOnce(new Error('Error occurred'));
jest.spyOn(globalThis as any, 'fetch').mockRejectedValueOnce(new Error('Error occurred'));
await expect(getMissedUpdatesUsers({}, cursor)).rejects.toThrow('Error occurred');
expect(consoleSpy).toHaveBeenCalledWith('Error occurred while fetching discord user details');
});
Expand Down

0 comments on commit 3d5295d

Please sign in to comment.