@@ -921,6 +921,60 @@ describe("api", function () {
921921 } ) ;
922922 } ) ;
923923 } ) ;
924+ describe ( 'delete_backed_up_assets' , function ( ) {
925+ it ( 'should delete specific version IDs' , async function ( ) {
926+ this . timeout ( TIMEOUT . LARGE ) ;
927+
928+ // Process:
929+ // - Upload to the same public ID three times
930+ // - Delete a single version (string)
931+ // - Delete a two versions (array)
932+ // - Cleanup
933+
934+ // Perform three uploads
935+ const firstUpload = await uploadImage ( {
936+ public_id : PUBLIC_ID_BACKUP_1 ,
937+ backup : true
938+ } ) ;
939+
940+ const secondUpload = await uploadImage ( {
941+ public_id : PUBLIC_ID_BACKUP_1 ,
942+ backup : true ,
943+ angle : '0' , // To create a unique version
944+ overwrite : true
945+ } ) ;
946+
947+ const thirdUpload = await uploadImage ( {
948+ public_id : PUBLIC_ID_BACKUP_1 ,
949+ backup : true ,
950+ angle : '100' , // To create a unique version
951+ overwrite : true
952+ } ) ;
953+
954+ // Ensure all files were uploaded correctly
955+ expect ( firstUpload ) . not . to . be ( null ) ;
956+ expect ( secondUpload ) . not . to . be ( null ) ;
957+ expect ( thirdUpload ) . not . to . be ( null ) ;
958+
959+ // Get the asset ID and versions of the uploaded asset
960+ const resourceResp = await API_V2 . resource ( PUBLIC_ID_BACKUP_1 , { versions : true } ) ;
961+ const assetId = resourceResp . asset_id ;
962+ const firstAssetVersion = resourceResp . versions [ 0 ] . version_id ;
963+ const secondAssetVersion = resourceResp . versions [ 1 ] . version_id ;
964+ const thirdAssetVersion = resourceResp . versions [ 2 ] . version_id ;
965+
966+ // Delete the first version
967+ const removeSingleVersion = await cloudinary . v2 . api . delete_backed_up_assets ( assetId , firstAssetVersion ) ;
968+ const removeSingleVersionResp = await API_V2 . resource ( PUBLIC_ID_BACKUP_1 , { versions : true } ) ;
969+ expect ( removeSingleVersionResp . versions ) . not . to . contain ( firstAssetVersion ) ;
970+
971+ // Delete the remaining two versions
972+ const removeMultipleVersions = await cloudinary . v2 . api . delete_backed_up_assets ( assetId , [ secondAssetVersion , thirdAssetVersion ] ) ;
973+ const removeMultipleVersionsResp = await API_V2 . resource ( PUBLIC_ID_BACKUP_1 , { versions : true } ) ;
974+ expect ( removeMultipleVersionsResp . versions ) . not . to . contain ( secondAssetVersion ) ;
975+ expect ( removeMultipleVersionsResp . versions ) . not . to . contain ( thirdAssetVersion ) ;
976+ } ) ;
977+ } ) ;
924978 describe ( "update" , function ( ) {
925979 describe ( "notification url" , function ( ) {
926980 var writeSpy , xhr ;
0 commit comments