@@ -26,7 +26,7 @@ jest.mock('@sentry/utils', () => {
2626import * as Sentry from '@sentry/browser' ;
2727
2828import { WINDOW } from '../../../src/constants' ;
29- import { makeSession } from '../../../src/session/Session' ;
29+ import { makeSession , sampleSession } from '../../../src/session/Session' ;
3030
3131type CaptureEventMockType = jest . MockedFunction < typeof Sentry . captureEvent > ;
3232
@@ -39,51 +39,33 @@ afterEach(() => {
3939} ) ;
4040
4141it ( 'does not sample' , function ( ) {
42- const newSession = makeSession (
43- { } ,
44- {
45- sessionSampleRate : 0.0 ,
46- errorSampleRate : 0.0 ,
47- } ,
48- ) ;
42+ const newSession = makeSession ( {
43+ sampled : sampleSession ( undefined , 0 , 0 ) ,
44+ } ) ;
4945
5046 expect ( newSession . sampled ) . toBe ( false ) ;
5147} ) ;
5248
5349it ( 'samples using `sessionSampleRate`' , function ( ) {
54- const newSession = makeSession (
55- { } ,
56- {
57- sessionSampleRate : 1.0 ,
58- errorSampleRate : 0.0 ,
59- } ,
60- ) ;
50+ const newSession = makeSession ( {
51+ sampled : sampleSession ( undefined , 1.0 , 0 ) ,
52+ } ) ;
6153
6254 expect ( newSession . sampled ) . toBe ( 'session' ) ;
6355} ) ;
6456
6557it ( 'samples using `errorSampleRate`' , function ( ) {
66- const newSession = makeSession (
67- { } ,
68- {
69- sessionSampleRate : 0 ,
70- errorSampleRate : 1.0 ,
71- } ,
72- ) ;
58+ const newSession = makeSession ( {
59+ sampled : sampleSession ( undefined , 0 , 1 ) ,
60+ } ) ;
7361
7462 expect ( newSession . sampled ) . toBe ( 'error' ) ;
7563} ) ;
7664
7765it ( 'does not run sampling function if existing session was sampled' , function ( ) {
78- const newSession = makeSession (
79- {
80- sampled : 'session' ,
81- } ,
82- {
83- sessionSampleRate : 0 ,
84- errorSampleRate : 0 ,
85- } ,
86- ) ;
66+ const newSession = makeSession ( {
67+ sampled : 'session' ,
68+ } ) ;
8769
8870 expect ( newSession . sampled ) . toBe ( 'session' ) ;
8971} ) ;
0 commit comments