diff --git a/__test__/unit/push/registerForPush.test.ts b/__test__/unit/push/registerForPush.test.ts index eac2d4e3e..fda38ce89 100644 --- a/__test__/unit/push/registerForPush.test.ts +++ b/__test__/unit/push/registerForPush.test.ts @@ -7,10 +7,18 @@ import BrowserUserAgent from '../../support/models/BrowserUserAgent'; //stub dismisshelper jest.mock('../../../src/shared/helpers/DismissHelper'); +//stub log +jest.mock('../../../src/shared/libraries/Log', () => ({ + debug: jest.fn(), + trace: jest.fn(), + info: jest.fn(), + warn: jest.fn(), + error: jest.fn(), +})); + describe('Register for push', () => { beforeEach(async () => { jest.useFakeTimers(); - jest.spyOn(Log, 'error').mockImplementation(() => {}) await TestEnvironment.initialize({ addPrompts: true, userAgent: BrowserUserAgent.Default, @@ -31,6 +39,7 @@ describe('Register for push', () => { expect(spy).not.toHaveBeenCalled(); OneSignalEvent.trigger(OneSignal.EVENTS.SDK_INITIALIZED); await promise; + expect(Log.error).toHaveBeenCalled(); expect(OneSignal.initialized).toBe(true); expect(spy).toHaveBeenCalledTimes(1); }); @@ -41,6 +50,7 @@ describe('Register for push', () => { const spy = jest.spyOn(InitHelper, 'registerForPushNotifications'); await InitHelper.registerForPushNotifications(); + expect(Log.error).toHaveBeenCalled(); expect(spy).toHaveBeenCalledTimes(1); }); });