@@ -63,10 +63,26 @@ describe('Scope', () => {
63
63
64
64
test ( 'addBreadcrumb' , ( ) => {
65
65
const scope = new Scope ( ) ;
66
- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
66
+ scope . addBreadcrumb ( { message : 'test' } ) ;
67
67
expect ( ( scope as any ) . _breadcrumbs [ 0 ] ) . toHaveProperty ( 'message' , 'test' ) ;
68
68
} ) ;
69
69
70
+ test ( 'addBreadcrumb can be limited to hold up to N breadcrumbs' , ( ) => {
71
+ const scope = new Scope ( ) ;
72
+ for ( let i = 0 ; i < 10 ; i ++ ) {
73
+ scope . addBreadcrumb ( { message : 'test' } , 5 ) ;
74
+ }
75
+ expect ( ( scope as any ) . _breadcrumbs ) . toHaveLength ( 5 ) ;
76
+ } ) ;
77
+
78
+ test ( 'addBreadcrumb cannot go over MAX_BREADCRUMBS value' , ( ) => {
79
+ const scope = new Scope ( ) ;
80
+ for ( let i = 0 ; i < 111 ; i ++ ) {
81
+ scope . addBreadcrumb ( { message : 'test' } , 111 ) ;
82
+ }
83
+ expect ( ( scope as any ) . _breadcrumbs ) . toHaveLength ( 100 ) ;
84
+ } ) ;
85
+
70
86
test ( 'setLevel' , ( ) => {
71
87
const scope = new Scope ( ) ;
72
88
scope . setLevel ( Severity . Critical ) ;
@@ -181,7 +197,7 @@ describe('Scope', () => {
181
197
scope . setFingerprint ( [ 'abcd' ] ) ;
182
198
scope . setLevel ( Severity . Warning ) ;
183
199
scope . setTransactionName ( '/abc' ) ;
184
- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
200
+ scope . addBreadcrumb ( { message : 'test' } ) ;
185
201
scope . setContext ( 'os' , { id : '1' } ) ;
186
202
const event : Event = { } ;
187
203
return scope . applyToEvent ( event ) . then ( processedEvent => {
@@ -203,7 +219,7 @@ describe('Scope', () => {
203
219
scope . setTag ( 'a' , 'b' ) ;
204
220
scope . setUser ( { id : '1' } ) ;
205
221
scope . setFingerprint ( [ 'abcd' ] ) ;
206
- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
222
+ scope . addBreadcrumb ( { message : 'test' } ) ;
207
223
scope . setContext ( 'server' , { id : '2' } ) ;
208
224
const event : Event = {
209
225
breadcrumbs : [ { message : 'test1' } ] ,
@@ -358,7 +374,7 @@ describe('Scope', () => {
358
374
scope . setTag ( 'a' , 'b' ) ;
359
375
scope . setUser ( { id : '1' } ) ;
360
376
scope . setFingerprint ( [ 'abcd' ] ) ;
361
- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
377
+ scope . addBreadcrumb ( { message : 'test' } ) ;
362
378
scope . setRequestSession ( { status : RequestSessionStatus . Ok } ) ;
363
379
expect ( ( scope as any ) . _extra ) . toEqual ( { a : 2 } ) ;
364
380
scope . clear ( ) ;
@@ -368,7 +384,7 @@ describe('Scope', () => {
368
384
369
385
test ( 'clearBreadcrumbs' , ( ) => {
370
386
const scope = new Scope ( ) ;
371
- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
387
+ scope . addBreadcrumb ( { message : 'test' } ) ;
372
388
expect ( ( scope as any ) . _breadcrumbs ) . toHaveLength ( 1 ) ;
373
389
scope . clearBreadcrumbs ( ) ;
374
390
expect ( ( scope as any ) . _breadcrumbs ) . toHaveLength ( 0 ) ;
0 commit comments