@causalfoundry/js-sdk
Version:
Causal Foundry WEB SDK (JS/TS)
55 lines (41 loc) • 1.55 kB
text/typescript
/**
* @jest-environment jsdom
*/
import CfCore from "../../core/CfCore";
import Navigation from "../Navigation"
import { SearchProperties } from "../Navigation/typings";
import {NavigationTypes} 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)
})
})
})