File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
packages/shared/sdk-client/src/configuration Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ describe('Configuration', () => {
2626 logLevel : 1 ,
2727 name : 'LaunchDarkly' ,
2828 } ,
29+ maxCachedContexts : 5 ,
2930 privateAttributes : [ ] ,
3031 sendEvents : true ,
3132 sendLDHeaders : true ,
@@ -69,7 +70,7 @@ describe('Configuration', () => {
6970 ) ;
7071 } ) ;
7172
72- test ( 'enforce minimum' , ( ) => {
73+ test ( 'enforce minimum flushInterval ' , ( ) => {
7374 const config = new Configuration ( { flushInterval : 1 } ) ;
7475
7576 expect ( config . flushInterval ) . toEqual ( 2 ) ;
@@ -89,4 +90,21 @@ describe('Configuration', () => {
8990 expect . stringMatching ( / s h o u l d b e o f t y p e L D F l a g S e t , g o t s t r i n g / i) ,
9091 ) ;
9192 } ) ;
93+
94+ test ( 'recognize maxCachedContexts' , ( ) => {
95+ const config = new Configuration ( { maxCachedContexts : 3 } ) ;
96+
97+ expect ( config . maxCachedContexts ) . toBeDefined ( ) ;
98+ expect ( console . error ) . not . toHaveBeenCalled ( ) ;
99+ } ) ;
100+
101+ test ( 'enforce minimum maxCachedContext' , ( ) => {
102+ const config = new Configuration ( { maxCachedContexts : - 1 } ) ;
103+
104+ expect ( config . maxCachedContexts ) . toBeDefined ( ) ;
105+ expect ( console . error ) . toHaveBeenNthCalledWith (
106+ 1 ,
107+ expect . stringContaining ( 'had invalid value of -1' ) ,
108+ ) ;
109+ } ) ;
92110} ) ;
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ class ConnectionModeValidator implements TypeValidator {
2727const validators : Record < keyof LDOptions , TypeValidator > = {
2828 initialConnectionMode : new ConnectionModeValidator ( ) ,
2929 logger : TypeValidators . Object ,
30+ maxCachedContexts : TypeValidators . numberWithMin ( 0 ) ,
3031
3132 baseUri : TypeValidators . String ,
3233 streamUri : TypeValidators . String ,
You can’t perform that action at this time.
0 commit comments