From 2a4587c516eb4535d34055385251a824118b93ba Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Tue, 14 Nov 2023 20:33:39 +0000 Subject: [PATCH] add test for notification click listner --- .../unit/notifications/eventListeners.test.ts | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 __test__/unit/notifications/eventListeners.test.ts diff --git a/__test__/unit/notifications/eventListeners.test.ts b/__test__/unit/notifications/eventListeners.test.ts new file mode 100644 index 000000000..722150300 --- /dev/null +++ b/__test__/unit/notifications/eventListeners.test.ts @@ -0,0 +1,22 @@ +import { TestEnvironment } from '../../support/environment/TestEnvironment'; +import EventHelper from '../../../src/shared/helpers/EventHelper'; + +describe('Notification Events', () => { + beforeEach(async () => { + TestEnvironment.initialize(); + }); + + afterEach(() => { + jest.resetAllMocks(); + }); + + test('Adding click listener fires internal EventHelper', async () => { + const stub = test.stub( + EventHelper, + 'fireStoredNotificationClicks', + null, + ); + OneSignal.Notifications.addEventListener('click', null); + expect(stub).toHaveBeenCalledTimes(1); + }); +});