UNPKG

@causalfoundry/js-sdk

Version:

Causal Foundry WEB SDK (JS/TS)

70 lines (59 loc) 1.55 kB
/** * @jest-environment jsdom */ import CfCore from "../../core/CfCore"; import Navigation from "../Navigation"; import { NavigationTypes, SearchProperties, } from "../../modules/Navigation/typings"; let windowSpy; let mockDeferredRunner; class MockImpressionsDetector { start() {} stop() {} restart() {} } describe("Navigation", () => { beforeEach(() => { mockDeferredRunner = { activate() {}, execute() {}, }; windowSpy = jest.spyOn(window, "window", "get"); }); afterEach(() => { // to remove the singleton instance (CfCore as any).instance = null; }); describe("[Loader] Navigation", () => { it('Should deliver a "Search" event with the same ID', async () => { Navigation.init(mockDeferredRunner); const firstID = Navigation.logIngestEvent( NavigationTypes.Search, {} as SearchProperties, true ); const secondID = Navigation.logIngestEvent( NavigationTypes.Search, {} as SearchProperties, false ); expect(firstID).toEqual(secondID); }); it('Should deliver a "Search" event with different ID', async () => { Navigation.init(mockDeferredRunner); const firstID = Navigation.logIngestEvent( NavigationTypes.Search, {} as SearchProperties, true ); const secondID = Navigation.logIngestEvent( NavigationTypes.Search, {} as SearchProperties, true ); expect(firstID).not.toEqual(secondID); }); }); });