1- import { buildUrl , buildVideoUrl , getConfig , setConfig } from '../lib/index'
1+ import { buildImageUrl , buildUrl , buildVideoUrl , extractPublicId , getConfig , RESOURCE_TYPES , setConfig , Transformer } from '../lib/index'
2+ import { RESOURCE_TYPES as OriginalResourceTypes , STORAGE_TYPES as OriginalStorageTypes , ROTATION_MODES as OriginalRotationModes , STORAGE_TYPES , ROTATION_MODES } from '../lib/constants'
3+ import { extractPublicId as originalExtractPublicId } from '../lib/url'
4+ import { transform , toTransformationStr } from '../lib/transformers'
25
36describe ( 'General tests' , ( ) => {
47 it ( 'configurations' , ( ) => {
@@ -12,6 +15,13 @@ describe('General tests', () => {
1215 } )
1316
1417 describe ( 'buildUrl()' , ( ) => {
18+ it ( 'should return default transformation' , ( ) => {
19+ expect ( buildUrl ( 'example' , {
20+ cloud : {
21+ cloudName : 'demo'
22+ }
23+ } ) ) . toBe ( 'https://res.cloudinary.com/demo/image/upload/q_auto,f_auto/example' )
24+ } ) ;
1525 it ( 'should return right url with configurations' , ( ) => {
1626 setConfig ( {
1727 cloudName : 'm'
@@ -48,6 +58,24 @@ describe('General tests', () => {
4858 cloudName : 'm'
4959 } )
5060 } ) ;
61+ } )
62+
63+ describe ( 'buildVideoUrl()' , ( ) => {
64+ it ( 'should return url with default config when no cloud' , ( ) => {
65+ setConfig ( {
66+ cloudName : 'demo'
67+ } )
68+
69+ expect ( buildVideoUrl ( 'example' , { transformations : { } } ) ) . toBe ( 'https://res.cloudinary.com/demo/video/upload/q_auto,f_auto/example' )
70+ } ) ;
71+
72+ it ( 'should return url with default config' , ( ) => {
73+ setConfig ( {
74+ cloudName : 'demo'
75+ } )
76+
77+ expect ( buildVideoUrl ( 'example' , { } ) ) . toBe ( 'https://res.cloudinary.com/demo/video/upload/q_auto,f_auto/example' )
78+ } ) ;
5179
5280 it ( 'should return right url format for video' , ( ) => {
5381 expect ( buildVideoUrl ( 'example' , {
@@ -63,5 +91,61 @@ describe('General tests', () => {
6391 } ) ) . toEqual ( 'https://res.cloudinary.com/demo/video/upload/c_scale,w_200,q_auto,f_auto/example' )
6492
6593 } )
66- } )
94+ } ) ;
95+
96+ describe ( 'buildImageUrl()' , ( ) => {
97+
98+ it ( 'should return url with default config when no cloud' , ( ) => {
99+ setConfig ( {
100+ cloudName : 'demo'
101+ } )
102+
103+ expect ( buildImageUrl ( 'example' , { transformations : { } } ) ) . toBe ( 'https://res.cloudinary.com/demo/image/upload/q_auto,f_auto/example' )
104+ } ) ;
105+ it ( 'should return url with default config' , ( ) => {
106+ setConfig ( {
107+ cloudName : 'demo'
108+ } )
109+
110+ expect ( buildImageUrl ( 'example' , { } ) ) . toBe ( 'https://res.cloudinary.com/demo/image/upload/q_auto,f_auto/example' )
111+ } ) ;
112+
113+ it ( 'should return url with cloud config' , ( ) => {
114+
115+ expect ( buildImageUrl ( 'example' , {
116+ cloud : {
117+ cloudName : 'demo'
118+ } ,
119+ transformations : {
120+ rotate : 10 ,
121+ }
122+ } ) ) . toBe ( 'https://res.cloudinary.com/demo/image/upload/q_auto,a_10,f_auto/example' )
123+ } ) ;
124+ } ) ;
125+
126+ describe ( 'exports' , ( ) => {
127+ it ( 'should export resourceTypes' , ( ) => {
128+ expect ( RESOURCE_TYPES ) . toEqual ( OriginalResourceTypes )
129+ } ) ;
130+
131+ it ( 'should export extractPublicId' , ( ) => {
132+ expect ( extractPublicId ) . toEqual ( extractPublicId )
133+ } ) ;
134+
135+ it ( 'should export STORAGE_TYPES' , ( ) => {
136+ expect ( STORAGE_TYPES ) . toEqual ( OriginalStorageTypes )
137+ } ) ;
138+
139+ it ( 'should export ROTATION_MODES' , ( ) => {
140+ expect ( ROTATION_MODES ) . toEqual ( OriginalRotationModes )
141+ } ) ;
142+
143+ it ( 'should export transform' , ( ) => {
144+ expect ( Transformer . transform ) . toEqual ( transform )
145+ } ) ;
146+
147+ it ( 'should export toTransformationStr' , ( ) => {
148+ expect ( Transformer . toString ) . toEqual ( toTransformationStr )
149+ } ) ;
150+ } ) ;
67151} )
0 commit comments