UNPKG

@benshi.ai/js-sdk

Version:

Benshi SDK

54 lines (41 loc) 1.48 kB
/** * @jest-environment jsdom */ import BsCore from "../../core/BsCore"; import { ICatalogRepository } from "../../core/repositories/catalog/CatalogRepository"; import Navigation from "../Navigation" import { SearchProperties } from "../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 (BsCore as any).instance = null }) describe('[Loader] Navigation', () => { it('Should deliver a "Search" event with the same ID', async () => { Navigation.init(mockDeferredRunner) const firstID = Navigation.logSearchEvent({} as SearchProperties, true) const secondID = Navigation.logSearchEvent({} as SearchProperties, false) expect(firstID).toEqual(secondID) }) it('Should deliver a "Search" event with different ID', async () => { Navigation.init(mockDeferredRunner) const firstID = Navigation.logSearchEvent({} as SearchProperties, true) const secondID = Navigation.logSearchEvent({} as SearchProperties, true) expect(firstID).not.toEqual(secondID) }) }) })