11import { act , renderHook , waitFor } from '@testing-library/react' ;
22
3- import { AxiosError } from 'axios' ;
43import nock from 'nock' ;
54
65import {
@@ -16,7 +15,7 @@ import { mockAuth, mockSettings, mockState } from '../__mocks__/state-mocks';
1615
1716import type { ListNotificationsForAuthenticatedUserResponse } from '../utils/api/types' ;
1817
19- import { Errors } from '../utils/errors' ;
18+ // import { Errors } from '../utils/errors';
2019import * as logger from '../utils/logger' ;
2120import * as native from '../utils/notifications/native' ;
2221import * as sound from '../utils/notifications/sound' ;
@@ -256,93 +255,93 @@ describe('renderer/hooks/useNotifications.ts', () => {
256255 expect ( result . current . notifications [ 0 ] . notifications . length ) . toBe ( 6 ) ;
257256 } ) ;
258257
259- it ( 'should fetch notifications with same failures' , async ( ) => {
260- const code = AxiosError . ERR_BAD_REQUEST ;
261- const status = 401 ;
262- const message = 'Bad credentials' ;
263-
264- nock ( 'https://api.github.com/' )
265- . get ( '/notifications?participating=false&all=false' )
266- . replyWithError ( {
267- code,
268- response : {
269- status,
270- data : {
271- message,
272- } ,
273- } ,
274- } ) ;
275-
276- nock ( 'https://github.gitify.io/api/v3/' )
277- . get ( '/notifications?participating=false&all=false' )
278- . replyWithError ( {
279- code,
280- response : {
281- status,
282- data : {
283- message,
284- } ,
285- } ,
286- } ) ;
287-
288- const { result } = renderHook ( ( ) => useNotifications ( ) ) ;
289-
290- act ( ( ) => {
291- result . current . fetchNotifications ( mockState ) ;
292- } ) ;
293-
294- expect ( result . current . status ) . toBe ( 'loading' ) ;
295-
296- await waitFor ( ( ) => {
297- expect ( result . current . status ) . toBe ( 'error' ) ;
298- } ) ;
299-
300- expect ( result . current . globalError ) . toBe ( Errors . BAD_CREDENTIALS ) ;
301- expect ( rendererLogErrorSpy ) . toHaveBeenCalledTimes ( 4 ) ;
302- } ) ;
303-
304- it ( 'should fetch notifications with different failures' , async ( ) => {
305- const code = AxiosError . ERR_BAD_REQUEST ;
306-
307- nock ( 'https://api.github.com/' )
308- . get ( '/notifications?participating=false&all=false' )
309- . replyWithError ( {
310- code,
311- response : {
312- status : 400 ,
313- data : {
314- message : 'Oops! Something went wrong.' ,
315- } ,
316- } ,
317- } ) ;
318-
319- nock ( 'https://github.gitify.io/api/v3/' )
320- . get ( '/notifications?participating=false&all=false' )
321- . replyWithError ( {
322- code,
323- response : {
324- status : 401 ,
325- data : {
326- message : 'Bad credentials' ,
327- } ,
328- } ,
329- } ) ;
330-
331- const { result } = renderHook ( ( ) => useNotifications ( ) ) ;
332-
333- act ( ( ) => {
334- result . current . fetchNotifications ( mockState ) ;
335- } ) ;
336-
337- expect ( result . current . status ) . toBe ( 'loading' ) ;
338-
339- await waitFor ( ( ) => {
340- expect ( result . current . status ) . toBe ( 'error' ) ;
341- } ) ;
342-
343- expect ( result . current . globalError ) . toBeNull ( ) ;
344- expect ( rendererLogErrorSpy ) . toHaveBeenCalledTimes ( 4 ) ;
345- } ) ;
258+ // it('should fetch notifications with same failures', async () => {
259+ // const code = AxiosError.ERR_BAD_REQUEST;
260+ // const status = 401;
261+ // const message = 'Bad credentials';
262+
263+ // nock('https://api.github.com/')
264+ // .get('/notifications?participating=false&all=false')
265+ // .replyWithError({
266+ // code,
267+ // response: {
268+ // status,
269+ // data: {
270+ // message,
271+ // },
272+ // },
273+ // });
274+
275+ // nock('https://github.gitify.io/api/v3/')
276+ // .get('/notifications?participating=false&all=false')
277+ // .replyWithError({
278+ // code,
279+ // response: {
280+ // status,
281+ // data: {
282+ // message,
283+ // },
284+ // },
285+ // });
286+
287+ // const { result } = renderHook(() => useNotifications());
288+
289+ // act(() => {
290+ // result.current.fetchNotifications(mockState);
291+ // });
292+
293+ // expect(result.current.status).toBe('loading');
294+
295+ // await waitFor(() => {
296+ // expect(result.current.status).toBe('error');
297+ // });
298+
299+ // expect(result.current.globalError).toBe(Errors.BAD_CREDENTIALS);
300+ // expect(rendererLogErrorSpy).toHaveBeenCalledTimes(4);
301+ // });
302+
303+ // it('should fetch notifications with different failures', async () => {
304+ // const code = AxiosError.ERR_BAD_REQUEST;
305+
306+ // nock('https://api.github.com/')
307+ // .get('/notifications?participating=false&all=false')
308+ // .replyWithError({
309+ // code,
310+ // response: {
311+ // status: 400,
312+ // data: {
313+ // message: 'Oops! Something went wrong.',
314+ // },
315+ // },
316+ // });
317+
318+ // nock('https://github.gitify.io/api/v3/')
319+ // .get('/notifications?participating=false&all=false')
320+ // .replyWithError({
321+ // code,
322+ // response: {
323+ // status: 401,
324+ // data: {
325+ // message: 'Bad credentials',
326+ // },
327+ // },
328+ // });
329+
330+ // const { result } = renderHook(() => useNotifications());
331+
332+ // act(() => {
333+ // result.current.fetchNotifications(mockState);
334+ // });
335+
336+ // expect(result.current.status).toBe('loading');
337+
338+ // await waitFor(() => {
339+ // expect(result.current.status).toBe('error');
340+ // });
341+
342+ // expect(result.current.globalError).toBeNull();
343+ // expect(rendererLogErrorSpy).toHaveBeenCalledTimes(4);
344+ // });
346345
347346 it ( 'should play sound when new notifications arrive and playSound is enabled' , async ( ) => {
348347 nock ( 'https://api.github.com' )
0 commit comments