@@ -35,8 +35,10 @@ const {
3535 AssetAlreadyExists,
3636 AssetAlreadyAttached,
3737 ParentAssetOrChannelNotFound,
38+ SourceAssetOrChannelNotFound,
3839 ChildAssetOrChannelNotFound,
3940 SigningServiceError,
41+ DestinationAssetAlreadyExists,
4042} = require ( '../errors' ) ;
4143
4244describe ( 'dbom node' , ( ) => {
@@ -655,4 +657,46 @@ describe('dbom node', () => {
655657 . rejectedWith ( GatewayError ) ;
656658 } ) ;
657659 } ) ;
660+
661+ context ( 'transferAsset' , ( ) => {
662+ it ( 'should transfer asset' , ( done ) => {
663+ axiosMock ( 200 , 'stubResponse' , done ) ;
664+ dbom . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
665+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) . then ( ( resolve ) => {
666+ expect ( resolve ) . to . equal ( 'stubResponse' ) ;
667+ } ) ;
668+ dbom1 . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
669+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) . then ( ( resolve ) => {
670+ expect ( resolve ) . to . equal ( 'stubResponse' ) ;
671+ } ) ;
672+ } ) ;
673+
674+ it ( 'should return source asset not found error' , ( done ) => {
675+ axiosMock ( 404 , 'stubResponse' , done ) ;
676+ expect ( dbom . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
677+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) ) . to . be . rejectedWith ( SourceAssetOrChannelNotFound ) ;
678+ expect ( dbom1 . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
679+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) ) . to . be . rejectedWith ( SourceAssetOrChannelNotFound ) ;
680+ } ) ;
681+
682+ it ( 'should report if destination asset already exists' , ( done ) => {
683+ axiosMock ( 409 , {
684+ success : false ,
685+ status : 'Already Exists' ,
686+ error : 'Destination asset already exists' ,
687+ } , done ) ;
688+ expect ( dbom . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
689+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) ) . to . be . rejectedWith ( DestinationAssetAlreadyExists ) ;
690+ expect ( dbom1 . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
691+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) ) . to . be . rejectedWith ( DestinationAssetAlreadyExists ) ;
692+ } ) ;
693+
694+ it ( 'should return gateway error' , ( done ) => {
695+ axiosMock ( 500 , 'stubResponse' , done ) ;
696+ expect ( dbom . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
697+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) ) . to . be . rejectedWith ( GatewayError ) ;
698+ expect ( dbom1 . transferAsset ( 'sourceRepoID' , 'sourceChannelID' , 'sourceAssetID' ,
699+ 'destinationRepoID' , 'destinationChannelID' , 'destinationAssetID' ) ) . to . be . rejectedWith ( GatewayError ) ;
700+ } ) ;
701+ } ) ;
658702} ) ;
0 commit comments