File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ import { CloudinaryMedia } from "../../../src/assets/CloudinaryMedia" ;
2+ import { Effect } from "../../../src/actions/effect" ;
3+
4+ describe ( 'Tests for cloning' , ( ) => {
5+ it ( 'should clone resource' , ( ) => {
6+ const asset = new CloudinaryMedia ( 'sample' , { cloudName : 'demo' } ) ;
7+
8+ const cloneAsset = asset . clone ( ) ;
9+
10+ //add transformation to asset
11+ asset . effect ( Effect . sepia ( ) ) ;
12+
13+ //change public id of cloneAsset
14+ cloneAsset . setPublicID ( 'dog' ) ;
15+
16+ expect ( cloneAsset . toURL ( ) ) . toEqual ( 'https://res.cloudinary.com/demo/image/upload/dog' ) ;
17+ expect ( asset . toURL ( ) ) . toEqual ( 'https://res.cloudinary.com/demo/image/upload/e_sepia/sample' ) ;
18+ } ) ;
19+ } ) ;
20+
Original file line number Diff line number Diff line change 7575 "lunr" : " ^1.0.0" ,
7676 "moment" : " ^2.22.1" ,
7777 "sanitize-html" : " ^1.18.2"
78+ },
79+ "dependencies" : {
80+ "@types/lodash.clonedeep" : " ^4.5.6" ,
81+ "lodash.clonedeep" : " ^4.5.0"
7882 }
7983}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import {LayerAction} from "../actions/layer/LayerAction";
55import { Transformation } from "../transformation/Transformation" ;
66import ICloudConfig from "../config/interfaces/Config/ICloudConfig" ;
77import IURLConfig from "../config/interfaces/Config/IURLConfig" ;
8+ import cloneDeep from 'lodash/cloneDeep' ;
89
910
1011/**
@@ -50,7 +51,10 @@ class CloudinaryMedia extends CloudinaryTransformable {
5051 toURL ( ) : string {
5152 return this . createCloudinaryURL ( this . transformation ) ;
5253 }
53- }
5454
55+ clone ( ) : this {
56+ return cloneDeep ( this ) ;
57+ }
58+ }
5559
5660export { CloudinaryMedia } ;
You can’t perform that action at this time.
0 commit comments