diff --git a/__test__/unit/push/registerForPush.test.ts b/__test__/unit/push/registerForPush.test.ts index 76080a535..fda38ce89 100644 --- a/__test__/unit/push/registerForPush.test.ts +++ b/__test__/unit/push/registerForPush.test.ts @@ -1,11 +1,21 @@ import { TestEnvironment } from '../../support/environment/TestEnvironment'; import InitHelper from '../../../src/shared/helpers/InitHelper'; import OneSignalEvent from '../../../src/shared/services/OneSignalEvent'; +import Log from '../../../src/shared/libraries/Log'; 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(); @@ -29,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); }); @@ -39,6 +50,7 @@ describe('Register for push', () => { const spy = jest.spyOn(InitHelper, 'registerForPushNotifications'); await InitHelper.registerForPushNotifications(); + expect(Log.error).toHaveBeenCalled(); expect(spy).toHaveBeenCalledTimes(1); }); }); diff --git a/package.json b/package.json index 4d3266441..be6b5b5ce 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "build:staging": "ENV=staging yarn transpile:sources && ENV=staging yarn bundle-sw && ENV=staging yarn bundle-sdk && ENV=staging yarn bundle-page-sdk-es6 && ENV=staging build/scripts/publish.sh", "build:prod": "ENV=production yarn transpile:sources && ENV=production yarn bundle-sw && ENV=production yarn bundle-sdk && ENV=production yarn bundle-page-sdk-es6 && bundlesize && ENV=production build/scripts/publish.sh", "test": "NODE_OPTIONS=\"--trace-warnings --unhandled-rejections=warn\" yarn run jest --detectOpenHandles --forceExit --runInBand", + "test:watch": "NODE_OPTIONS=\"--trace-warnings --unhandled-rejections=warn\" yarn run jest --detectOpenHandles --forceExit --runInBand --watch", "publish": "yarn clean && yarn build:prod && yarn", "build:dev-dev": "./build/scripts/build.sh -f development -t development -a localhost", "build:dev-prod": "./build/scripts/build.sh -f development -t production",