@@ -3,8 +3,7 @@ import * as CreateSession from '../../../src/session/createSession';
33import * as FetchSession from '../../../src/session/fetchSession' ;
44import { getSession } from '../../../src/session/getSession' ;
55import { saveSession } from '../../../src/session/saveSession' ;
6- import { Session } from '../../../src/session/Session' ;
7- import { sessionToJSON } from '../../utils/sessionToJson' ;
6+ import { makeSession } from '../../../src/session/Session' ;
87
98jest . mock ( '@sentry/utils' , ( ) => {
109 return {
@@ -19,7 +18,7 @@ const SAMPLE_RATES = {
1918} ;
2019
2120function createMockSession ( when : number = new Date ( ) . getTime ( ) ) {
22- return new Session (
21+ return makeSession (
2322 {
2423 id : 'test_session_id' ,
2524 segmentId : 0 ,
@@ -53,7 +52,7 @@ it('creates a non-sticky session when one does not exist', function () {
5352 expect ( FetchSession . fetchSession ) . not . toHaveBeenCalled ( ) ;
5453 expect ( CreateSession . createSession ) . toHaveBeenCalled ( ) ;
5554
56- expect ( sessionToJSON ( session ) ) . toEqual ( {
55+ expect ( session ) . toEqual ( {
5756 id : 'test_session_id' ,
5857 segmentId : 0 ,
5958 lastActivity : expect . any ( Number ) ,
@@ -85,7 +84,7 @@ it('creates a non-sticky session, when one is expired', function () {
8584 expiry : 1000 ,
8685 stickySession : false ,
8786 ...SAMPLE_RATES ,
88- currentSession : new Session (
87+ currentSession : makeSession (
8988 {
9089 id : 'old_session_id' ,
9190 lastActivity : new Date ( ) . getTime ( ) - 1001 ,
@@ -116,7 +115,7 @@ it('creates a sticky session when one does not exist', function () {
116115 expect ( FetchSession . fetchSession ) . toHaveBeenCalled ( ) ;
117116 expect ( CreateSession . createSession ) . toHaveBeenCalled ( ) ;
118117
119- expect ( sessionToJSON ( session ) ) . toEqual ( {
118+ expect ( session ) . toEqual ( {
120119 id : 'test_session_id' ,
121120 segmentId : 0 ,
122121 lastActivity : expect . any ( Number ) ,
@@ -125,7 +124,7 @@ it('creates a sticky session when one does not exist', function () {
125124 } ) ;
126125
127126 // Should not have anything in storage
128- expect ( sessionToJSON ( FetchSession . fetchSession ( SAMPLE_RATES ) ! ) ) . toEqual ( {
127+ expect ( FetchSession . fetchSession ( SAMPLE_RATES ) ) . toEqual ( {
129128 id : 'test_session_id' ,
130129 segmentId : 0 ,
131130 lastActivity : expect . any ( Number ) ,
@@ -148,7 +147,7 @@ it('fetches an existing sticky session', function () {
148147 expect ( FetchSession . fetchSession ) . toHaveBeenCalled ( ) ;
149148 expect ( CreateSession . createSession ) . not . toHaveBeenCalled ( ) ;
150149
151- expect ( sessionToJSON ( session ) ) . toEqual ( {
150+ expect ( session ) . toEqual ( {
152151 id : 'test_session_id' ,
153152 segmentId : 0 ,
154153 lastActivity : now ,
@@ -181,7 +180,7 @@ it('fetches a non-expired non-sticky session', function () {
181180 expiry : 1000 ,
182181 stickySession : false ,
183182 ...SAMPLE_RATES ,
184- currentSession : new Session (
183+ currentSession : makeSession (
185184 {
186185 id : 'test_session_id_2' ,
187186 lastActivity : + new Date ( ) - 500 ,
0 commit comments