@@ -63,10 +63,26 @@ describe('Scope', () => {
6363
6464 test ( 'addBreadcrumb' , ( ) => {
6565 const scope = new Scope ( ) ;
66- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
66+ scope . addBreadcrumb ( { message : 'test' } ) ;
6767 expect ( ( scope as any ) . _breadcrumbs [ 0 ] ) . toHaveProperty ( 'message' , 'test' ) ;
6868 } ) ;
6969
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+
7086 test ( 'setLevel' , ( ) => {
7187 const scope = new Scope ( ) ;
7288 scope . setLevel ( Severity . Critical ) ;
@@ -181,7 +197,7 @@ describe('Scope', () => {
181197 scope . setFingerprint ( [ 'abcd' ] ) ;
182198 scope . setLevel ( Severity . Warning ) ;
183199 scope . setTransactionName ( '/abc' ) ;
184- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
200+ scope . addBreadcrumb ( { message : 'test' } ) ;
185201 scope . setContext ( 'os' , { id : '1' } ) ;
186202 const event : Event = { } ;
187203 return scope . applyToEvent ( event ) . then ( processedEvent => {
@@ -203,7 +219,7 @@ describe('Scope', () => {
203219 scope . setTag ( 'a' , 'b' ) ;
204220 scope . setUser ( { id : '1' } ) ;
205221 scope . setFingerprint ( [ 'abcd' ] ) ;
206- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
222+ scope . addBreadcrumb ( { message : 'test' } ) ;
207223 scope . setContext ( 'server' , { id : '2' } ) ;
208224 const event : Event = {
209225 breadcrumbs : [ { message : 'test1' } ] ,
@@ -358,7 +374,7 @@ describe('Scope', () => {
358374 scope . setTag ( 'a' , 'b' ) ;
359375 scope . setUser ( { id : '1' } ) ;
360376 scope . setFingerprint ( [ 'abcd' ] ) ;
361- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
377+ scope . addBreadcrumb ( { message : 'test' } ) ;
362378 scope . setRequestSession ( { status : RequestSessionStatus . Ok } ) ;
363379 expect ( ( scope as any ) . _extra ) . toEqual ( { a : 2 } ) ;
364380 scope . clear ( ) ;
@@ -368,7 +384,7 @@ describe('Scope', () => {
368384
369385 test ( 'clearBreadcrumbs' , ( ) => {
370386 const scope = new Scope ( ) ;
371- scope . addBreadcrumb ( { message : 'test' } , 100 ) ;
387+ scope . addBreadcrumb ( { message : 'test' } ) ;
372388 expect ( ( scope as any ) . _breadcrumbs ) . toHaveLength ( 1 ) ;
373389 scope . clearBreadcrumbs ( ) ;
374390 expect ( ( scope as any ) . _breadcrumbs ) . toHaveLength ( 0 ) ;
0 commit comments