1- import { PlayerAnalytics , IPlayerAnalyticsInitOptions } from "../src/PlayerAnalytics" ;
2- import { Reporter } from "../src/utils/Reporter" ;
1+ import {
2+ PlayerAnalytics ,
3+ IPlayerAnalyticsInitOptions ,
4+ } from "../src/PlayerAnalytics" ;
35import {
46 TPlayingEvent ,
57 TPausedEvent ,
@@ -157,7 +159,8 @@ describe("PlayerAnalytics", () => {
157159 expect ( mockFetch ) . toHaveBeenCalled ( ) ;
158160 const body = JSON . parse ( mockFetch . calls . argsFor ( 0 ) [ 1 ] . body ) ;
159161 expect ( body . event ) . toBe ( "playing" ) ;
160- expect ( body . sessionId ) . toBe ( "test-session" ) ;
162+ // Reporter uses its authoritative sessionId (from server init response)
163+ expect ( body . sessionId ) . toBe ( "test-session-id" ) ;
161164 } ) ;
162165
163166 it ( "should call reporter.send with correct data for pause()" , ( ) => {
@@ -295,7 +298,10 @@ describe("PlayerAnalytics", () => {
295298
296299 describe ( "debug mode" , ( ) => {
297300 it ( "should not call fetch when debug mode is enabled" , async ( ) => {
298- const analytics = new PlayerAnalytics ( "https://example.com/analytics" , true ) ;
301+ const analytics = new PlayerAnalytics (
302+ "https://example.com/analytics" ,
303+ true
304+ ) ;
299305
300306 spyOn ( console , "log" ) ;
301307
@@ -306,7 +312,10 @@ describe("PlayerAnalytics", () => {
306312 } ) ;
307313
308314 it ( "should log events to console in debug mode" , async ( ) => {
309- const analytics = new PlayerAnalytics ( "https://example.com/analytics" , true ) ;
315+ const analytics = new PlayerAnalytics (
316+ "https://example.com/analytics" ,
317+ true
318+ ) ;
310319
311320 spyOn ( console , "log" ) ;
312321
0 commit comments