@@ -270,4 +270,87 @@ describe("LibraryDataProvider", async function () {
270270
271271 deleteTableStub . restore ( ) ;
272272 } ) ;
273+
274+ it ( "deleteTables - deletes multiple tables successfully" , async ( ) => {
275+ const items : LibraryItem [ ] = [
276+ {
277+ uid : "lib.table1" ,
278+ id : "table1" ,
279+ name : "table1" ,
280+ type : "table" ,
281+ readOnly : false ,
282+ library : "lib" ,
283+ } ,
284+ {
285+ uid : "lib.table2" ,
286+ id : "table2" ,
287+ name : "table2" ,
288+ type : "table" ,
289+ readOnly : false ,
290+ library : "lib" ,
291+ } ,
292+ ] ;
293+
294+ const api = dataAccessApi ( ) ;
295+ const deleteTableStub = sinon . stub ( api , "deleteTable" ) ;
296+
297+ const provider = libraryDataProvider ( api ) ;
298+ await provider . deleteTables ( items ) ;
299+
300+ expect ( deleteTableStub . callCount ) . to . equal ( 2 ) ;
301+ deleteTableStub . restore ( ) ;
302+ } ) ;
303+
304+ it ( "deleteTables - reports failures when some tables fail to delete" , async ( ) => {
305+ const items : LibraryItem [ ] = [
306+ {
307+ uid : "lib.table1" ,
308+ id : "table1" ,
309+ name : "table1" ,
310+ type : "table" ,
311+ readOnly : false ,
312+ library : "lib" ,
313+ } ,
314+ {
315+ uid : "lib.table2" ,
316+ id : "table2" ,
317+ name : "table2" ,
318+ type : "table" ,
319+ readOnly : false ,
320+ library : "lib" ,
321+ } ,
322+ {
323+ uid : "lib.table3" ,
324+ id : "table3" ,
325+ name : "table3" ,
326+ type : "table" ,
327+ readOnly : false ,
328+ library : "lib" ,
329+ } ,
330+ ] ;
331+
332+ const api = dataAccessApi ( ) ;
333+ const deleteTableStub = sinon . stub ( api , "deleteTable" ) ;
334+
335+ // First table succeeds
336+ deleteTableStub . onFirstCall ( ) . resolves ( ) ;
337+ // Second table fails
338+ deleteTableStub
339+ . onSecondCall ( )
340+ . throwsException ( new Error ( "Failed to delete" ) ) ;
341+ // Third table succeeds
342+ deleteTableStub . onThirdCall ( ) . resolves ( ) ;
343+
344+ const provider = libraryDataProvider ( api ) ;
345+
346+ try {
347+ await provider . deleteTables ( items ) ;
348+ expect . fail ( "Should have thrown an error" ) ;
349+ } catch ( error ) {
350+ expect ( error . message ) . to . contain ( "lib.table2" ) ;
351+ expect ( deleteTableStub . callCount ) . to . equal ( 3 ) ;
352+ }
353+
354+ deleteTableStub . restore ( ) ;
355+ } ) ;
273356} ) ;
0 commit comments