@@ -157,6 +157,43 @@ test.it(
157157 } ,
158158) ;
159159
160+ test . it ( "should wait for table when it exists but is not ACTIVE" , async ( t ) => {
161+ const tableName = randomUUID ( ) ;
162+
163+ // First create a store and table
164+ const store = new KeyvDynamo ( {
165+ endpoint : dynamoURL ,
166+ tableName,
167+ } ) ;
168+ await store . set ( "test:key1" , "value1" ) ;
169+
170+ // Now test ensureTable directly with a mocked CREATING status
171+ let describeCallCount = 0 ;
172+ const originalSend = ( store as any ) . client . send ;
173+ ( store as any ) . client . send = test . vi
174+ . fn ( )
175+ . mockImplementation ( async ( command ) => {
176+ if ( command . constructor . name === "DescribeTableCommand" ) {
177+ describeCallCount ++ ;
178+ if ( describeCallCount === 1 ) {
179+ // First call returns CREATING status
180+ return {
181+ Table : {
182+ TableName : tableName ,
183+ TableStatus : "CREATING" ,
184+ } ,
185+ } ;
186+ }
187+ }
188+ return originalSend . call ( ( store as any ) . client , command ) ;
189+ } ) ;
190+
191+ // Call ensureTable directly - this should hit the CREATING branch
192+ await store . ensureTable ( tableName ) ;
193+ t . expect ( describeCallCount ) . toBeGreaterThanOrEqual ( 1 ) ;
194+ ( store as any ) . client . send = originalSend ;
195+ } ) ;
196+
160197test . it ( "should verify exposed client property" , async ( t ) => {
161198 const store = new KeyvDynamo ( { endpoint : dynamoURL } ) ;
162199 t . expect ( store . client ) . toBeDefined ( ) ;
0 commit comments