@@ -98,6 +98,20 @@ describe('asyncWithLDProvider', () => {
9898 expect ( receivedNode ) . toHaveTextContent ( '{"another-test-flag":false,"test-flag":false}' ) ;
9999 } ) ;
100100
101+ test ( 'consecutive flag changes gets stored in context correctly' , async ( ) => {
102+ mockLDClient . on . mockImplementationOnce ( ( e : string , cb : ( c : LDFlagChangeset ) => void ) => {
103+ cb ( { 'another-test-flag' : { current : false , previous : true } } ) ;
104+
105+ // simulate second update
106+ cb ( { 'test-flag' : { current : false , previous : true } } ) ;
107+ } ) ;
108+
109+ const receivedNode = await renderWithConfig ( { clientSideID } ) ;
110+
111+ expect ( mockLDClient . on ) . toHaveBeenNthCalledWith ( 1 , 'change' , expect . any ( Function ) ) ;
112+ expect ( receivedNode ) . toHaveTextContent ( '{"testFlag":false,"anotherTestFlag":false}' ) ;
113+ } ) ;
114+
101115 test ( 'ldClient bootstraps correctly' , async ( ) => {
102116 // don't subscribe to changes to test bootstrap
103117 mockLDClient . on . mockImplementation ( ( e : string , cb : ( c : LDFlagChangeset ) => void ) => {
@@ -113,6 +127,18 @@ describe('asyncWithLDProvider', () => {
113127 expect ( receivedNode ) . toHaveTextContent ( '{"anotherTestFlag":false,"testFlag":true}' ) ;
114128 } ) ;
115129
130+ test ( 'ldClient bootstraps with empty flags' , async ( ) => {
131+ // don't subscribe to changes to test bootstrap
132+ mockLDClient . on . mockImplementation ( ( e : string , cb : ( c : LDFlagChangeset ) => void ) => {
133+ return ;
134+ } ) ;
135+ const options : LDOptions = {
136+ bootstrap : { } ,
137+ } ;
138+ const receivedNode = await renderWithConfig ( { clientSideID, user, options } ) ;
139+ expect ( receivedNode ) . toHaveTextContent ( '{}' ) ;
140+ } ) ;
141+
116142 test ( 'ldClient bootstraps correctly with kebab-case' , async ( ) => {
117143 // don't subscribe to changes to test bootstrap
118144 mockLDClient . on . mockImplementation ( ( e : string , cb : ( c : LDFlagChangeset ) => void ) => {
@@ -146,7 +172,7 @@ describe('asyncWithLDProvider', () => {
146172 flags : { devTestFlag : true , launchDoggly : true } ,
147173 ldClient : mockLDClient ,
148174 } ) ) ;
149- const options : LDOptions = { bootstrap : { } } ;
175+ const options : LDOptions = { } ;
150176 const flags = { 'dev-test-flag' : false , 'launch-doggly' : false } ;
151177 const receivedNode = await renderWithConfig ( { clientSideID, user, options, flags } ) ;
152178
0 commit comments