@@ -2,6 +2,7 @@ import { act, renderHook, waitFor } from '@testing-library/react';
22import axios , { AxiosError } from 'axios' ;
33import nock from 'nock' ;
44
5+ import log from 'electron-log' ;
56import {
67 mockAuth ,
78 mockGitHubCloudAccount ,
@@ -16,10 +17,13 @@ import { Errors } from '../utils/constants';
1617import { useNotifications } from './useNotifications' ;
1718
1819describe ( 'hooks/useNotifications.ts' , ( ) => {
20+ const logErrorSpy = jest . spyOn ( log , 'error' ) . mockImplementation ( ) ;
21+
1922 beforeEach ( ( ) => {
2023 // axios will default to using the XHR adapter which can't be intercepted
2124 // by nock. So, configure axios to use the node adapter.
2225 axios . defaults . adapter = 'http' ;
26+ logErrorSpy . mockReset ( ) ;
2327 } ) ;
2428
2529 const id = mockSingleNotification . id ;
@@ -294,6 +298,7 @@ describe('hooks/useNotifications.ts', () => {
294298 } ) ;
295299
296300 expect ( result . current . globalError ) . toBe ( Errors . BAD_CREDENTIALS ) ;
301+ expect ( logErrorSpy ) . toHaveBeenCalledTimes ( 2 ) ;
297302 } ) ;
298303
299304 it ( 'should fetch notifications with different failures' , async ( ) => {
@@ -336,6 +341,7 @@ describe('hooks/useNotifications.ts', () => {
336341 } ) ;
337342
338343 expect ( result . current . globalError ) . toBeNull ( ) ;
344+ expect ( logErrorSpy ) . toHaveBeenCalledTimes ( 2 ) ;
339345 } ) ;
340346 } ) ;
341347
@@ -374,6 +380,7 @@ describe('hooks/useNotifications.ts', () => {
374380 } ) ;
375381
376382 expect ( result . current . notifications . length ) . toBe ( 0 ) ;
383+ expect ( logErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
377384 } ) ;
378385 } ) ;
379386
@@ -412,6 +419,7 @@ describe('hooks/useNotifications.ts', () => {
412419 } ) ;
413420
414421 expect ( result . current . notifications . length ) . toBe ( 0 ) ;
422+ expect ( logErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
415423 } ) ;
416424 } ) ;
417425
@@ -470,6 +478,7 @@ describe('hooks/useNotifications.ts', () => {
470478 } ) ;
471479
472480 expect ( result . current . notifications . length ) . toBe ( 0 ) ;
481+ expect ( logErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
473482 } ) ;
474483 } ) ;
475484
@@ -516,6 +525,7 @@ describe('hooks/useNotifications.ts', () => {
516525 } ) ;
517526
518527 expect ( result . current . notifications . length ) . toBe ( 0 ) ;
528+ expect ( logErrorSpy ) . toHaveBeenCalledTimes ( 1 ) ;
519529 } ) ;
520530 } ) ;
521531
0 commit comments