@@ -234,6 +234,57 @@ describe("ObjectStoreProvider", function () {
234234 }
235235 } ) ;
236236
237+ describe ( "clearStores and clearAllData" , ( ) => {
238+ const schema = {
239+ version : 1 ,
240+ stores : [
241+ {
242+ name : "store1" ,
243+ primaryKeyPath : "id" ,
244+ } ,
245+ {
246+ name : "store2" ,
247+ primaryKeyPath : "id" ,
248+ } ,
249+ ] ,
250+ } ;
251+ it ( "should delete the specific store" , async ( ) => {
252+ if ( provName . includes ( "memory" ) ) return ;
253+
254+ const prov = await openProvider ( provName , schema , true ) ;
255+ await prov . put ( "store1" , { id : "a" , val : "val-store-1" } ) ;
256+ await prov . put ( "store2" , { id : "a" , val : "val-store-2" } ) ;
257+ await prov . clearStores ( [ "store1" ] ) ;
258+
259+ const data = await prov . get ( "store1" , "a" ) ;
260+ assert ( ! data , "store1 should be cleared" ) ;
261+
262+ const data2 = await prov . get ( "store2" , "a" ) ;
263+ assert . equal ( ( data2 as TestObj ) ?. val , "val-store-2" , "store2 should remain intact" ) ;
264+
265+ await prov . close ( ) ;
266+ } ) ;
267+
268+ it ( "should delete all stores" , async ( ) => {
269+ if ( provName . includes ( "memory" ) ) return ;
270+
271+ const prov = await openProvider ( provName , schema , true ) ;
272+ await prov . put ( "store1" , { id : "a" , val : "val-store-1" } ) ;
273+ await prov . put ( "store2" , { id : "a" , val : "val-store-2" } ) ;
274+
275+ const beforeDeletion = await prov . get ( "store1" , "a" ) ;
276+ assert . equal ( ( beforeDeletion as TestObj ) ?. val , "val-store-1" , "store1 should contain data put before clearAllData" ) ;
277+
278+ await prov . clearAllData ( ) ;
279+
280+ const data = await prov . get ( "store1" , "a" ) ;
281+ assert ( ! data , "store1 should be cleared" ) ;
282+ const data2 = await prov . get ( "store2" , "a" ) ;
283+ assert ( ! data2 , "store2 should be cleared" ) ;
284+ await prov . close ( ) ;
285+ } ) ;
286+ } ) ;
287+
237288 describe ( "Expected database closure" , ( ) => {
238289 if ( provName . indexOf ( "indexeddbonclose" ) === - 1 ) {
239290 xit ( "Skip expected DB closure for in-memory provider" , ( ) => {
0 commit comments