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 75
75
"lunr" : " ^1.0.0" ,
76
76
"moment" : " ^2.22.1" ,
77
77
"sanitize-html" : " ^1.18.2"
78
+ },
79
+ "dependencies" : {
80
+ "@types/lodash.clonedeep" : " ^4.5.6" ,
81
+ "lodash.clonedeep" : " ^4.5.0"
78
82
}
79
83
}
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import {LayerAction} from "../actions/layer/LayerAction";
5
5
import { Transformation } from "../transformation/Transformation" ;
6
6
import ICloudConfig from "../config/interfaces/Config/ICloudConfig" ;
7
7
import IURLConfig from "../config/interfaces/Config/IURLConfig" ;
8
+ import cloneDeep from 'lodash/cloneDeep' ;
8
9
9
10
10
11
/**
@@ -50,7 +51,10 @@ class CloudinaryMedia extends CloudinaryTransformable {
50
51
toURL ( ) : string {
51
52
return this . createCloudinaryURL ( this . transformation ) ;
52
53
}
53
- }
54
54
55
+ clone ( ) : this {
56
+ return cloneDeep ( this ) ;
57
+ }
58
+ }
55
59
56
60
export { CloudinaryMedia } ;
You can’t perform that action at this time.
0 commit comments