@@ -1461,6 +1461,8 @@ describe("api", function () {
14611461 this . timeout ( TIMEOUT . MEDIUM ) ;
14621462
14631463 const publicId = "api_test_restore" + UNIQUE_JOB_SUFFIX_ID ;
1464+ let uploadedAssetId ;
1465+
14641466 before ( ( ) => uploadImage ( {
14651467 public_id : publicId ,
14661468 backup : true ,
@@ -1469,6 +1471,7 @@ describe("api", function () {
14691471 . then ( wait ( 2000 ) )
14701472 . then ( ( ) => cloudinary . v2 . api . resource ( publicId ) )
14711473 . then ( ( resource ) => {
1474+ uploadedAssetId = resource . asset_id ;
14721475 expect ( resource ) . not . to . be ( null ) ;
14731476 expect ( resource . bytes ) . to . eql ( 3381 ) ;
14741477 return cloudinary . v2 . api . delete_resources ( publicId ) ;
@@ -1480,17 +1483,19 @@ describe("api", function () {
14801483 expect ( resource . placeholder ) . to . eql ( true ) ;
14811484 } )
14821485 ) ;
1486+
14831487 it ( "should restore a deleted resource when passed an asset ID" , ( ) => cloudinary . v2 . api
1484- . restore ( assetId )
1488+ . restore_by_asset_id ( [ uploadedAssetId ] )
14851489 . then ( ( response ) => {
1486- let info = response [ assetId ] ;
1490+ let info = response [ uploadedAssetId ] ;
14871491 expect ( info ) . not . to . be ( null ) ;
14881492 expect ( info . bytes ) . to . eql ( 3381 ) ;
1489- return cloudinary . v2 . api . resource ( assetId ) ;
1493+ return cloudinary . v2 . api . resources_by_asset_ids ( [ uploadedAssetId ] ) ;
14901494 } )
1491- . then ( ( resource ) => {
1492- expect ( resource ) . not . to . be ( null ) ;
1493- expect ( resource . bytes ) . to . eql ( 3381 ) ;
1495+ . then ( ( response ) => {
1496+ const { resources } = response ;
1497+ expect ( resources [ 0 ] ) . not . to . be ( null ) ;
1498+ expect ( resources [ 0 ] . bytes ) . to . eql ( 3381 ) ;
14941499 } ) ) ;
14951500
14961501 it ( "should restore different versions of a deleted asset when passed an asset ID" , async function ( ) {
@@ -1544,16 +1549,17 @@ describe("api", function () {
15441549
15451550 // Restore first version by passing in the asset ID, ensure it's equal to the upload size
15461551 await wait ( 1000 ) ( ) ;
1547- const firstVerRestore = await API_V2 . restore ( [ assetId ] , {
1552+ const firstVerRestore = await API_V2 . restore_by_asset_id ( [ assetId ] , {
15481553 versions : [ firstAssetVersion ]
15491554 } ) ;
1555+
15501556 expect ( firstVerRestore [ assetId ] . bytes ) . to . eql (
15511557 firstUpload . bytes
15521558 ) ;
15531559
15541560 // Restore second version by passing in the asset ID, ensure it's equal to the upload size
15551561 await wait ( 1000 ) ( ) ;
1556- const secondVerRestore = await API_V2 . restore (
1562+ const secondVerRestore = await API_V2 . restore_by_asset_id (
15571563 [ assetId ] ,
15581564 { versions : [ secondAssetVersion ] }
15591565 ) ;
@@ -1594,7 +1600,7 @@ describe("api", function () {
15941600 PUBLIC_ID_BACKUP_1 ,
15951601 { versions : true }
15961602 ) ;
1597-
1603+
15981604 const getSecondAssetVersion = await API_V2 . resource (
15991605 PUBLIC_ID_BACKUP_2 ,
16001606 { versions : true }
@@ -1611,7 +1617,7 @@ describe("api", function () {
16111617 const IDS_TO_RESTORE = [ firstAssetId , secondAssetId ] ;
16121618 const VERSIONS_TO_RESTORE = [ firstAssetVersion , secondAssetVersion ] ;
16131619
1614- const restore = await API_V2 . restore ( IDS_TO_RESTORE , {
1620+ const restore = await API_V2 . restore_by_asset_id ( IDS_TO_RESTORE , {
16151621 versions : VERSIONS_TO_RESTORE
16161622 } ) ;
16171623
@@ -1634,7 +1640,7 @@ describe("api", function () {
16341640 } ) ;
16351641 } ) ;
16361642
1637-
1643+
16381644 describe ( 'mapping' , function ( ) {
16391645 before ( function ( ) {
16401646 this . mapping = `api_test_upload_mapping${ Math . floor ( Math . random ( ) * 100000 ) } ` ;
0 commit comments