import { DAnalytics, TConfig } from "../src/danalytics"; import { dlog } from "../src/dlog"; describe("DAnalytics initSession", () => { beforeEach(() => {}); it("should call the launch API and store the session key", async () => { const config: TConfig = { server: "simplestore.dipankar.co.in", app_id: "corexxx", debug: false, }; // Create instance and wait for session to initialize const analytics = new DAnalytics(config); // Wait for the async initSession to complete await new Promise((resolve) => setTimeout(resolve, 1000)); expect(analytics["sessionKey"]).toBeDefined(); // test action: const result = await analytics.trackAction("click", "btn1", "btn_click"); expect(result).toMatchObject({ status: "success" }); // adhoc action dlog.i("This is a sample test console log", { Hello: 100 }); const result1 = await analytics.trackConsoleLog(); expect(result1).toMatchObject({ status: "success" }); }); });