1- import React from ' react' ;
2- import { expect } from ' chai' ;
3- import { shallow , mount , render } from ' enzyme' ;
4- import Image from ' ../src/components/Image' ;
5- import Transformation from ' ../src/components/Transformation' ;
1+ import React from " react" ;
2+ import { expect } from " chai" ;
3+ import { shallow , mount , render } from " enzyme" ;
4+ import Image from " ../src/components/Image" ;
5+ import Transformation from " ../src/components/Transformation" ;
66
7-
8- describe ( 'Transformation' , ( ) => {
9- beforeEach ( ( ) => {
10- } ) ;
7+ describe ( "Transformation" , ( ) => {
8+ beforeEach ( ( ) => { } ) ;
119 it ( "should create an img tag" , function ( ) {
1210 let tag = shallow (
13- < Image publicId = "sample" cloudName = "demo" >
14- < Transformation width = "100" crop = "scale" angle = "10" />
11+ < Image publicId = "sample" cloudName = "demo" >
12+ < Transformation width = "100" crop = "scale" angle = "10" />
1513 </ Image >
1614 ) ;
1715 expect ( tag . name ( ) ) . to . equal ( "img" ) ;
18- expect ( tag . state ( "url" ) ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/a_10,c_scale,w_100/sample" ) ;
16+ expect ( tag . state ( "url" ) ) . to . equal (
17+ "http://res.cloudinary.com/demo/image/upload/a_10,c_scale,w_100/sample"
18+ ) ;
1919 } ) ;
2020 it ( "should allow chained transformations" , function ( ) {
2121 let tag = shallow (
22- < Image publicId = "sample" cloudName = "demo" >
23- < Transformation width = "100" crop = "scale" />
22+ < Image publicId = "sample" cloudName = "demo" >
23+ < Transformation width = "100" crop = "scale" />
2424 < Transformation width = "200" crop = "pad" >
25- < Transformation angle = "30" />
25+ < Transformation angle = "30" />
2626 </ Transformation >
2727 </ Image >
2828 ) ;
2929 expect ( tag . type ( ) ) . to . equal ( "img" ) ;
30- expect ( tag . state ( "url" ) ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/c_scale,w_100/a_30/c_pad,w_200/sample" ) ;
30+ expect ( tag . state ( "url" ) ) . to . equal (
31+ "http://res.cloudinary.com/demo/image/upload/c_scale,w_100/a_30/c_pad,w_200/sample"
32+ ) ;
33+ } ) ;
34+ it ( "array should define a set of variables" , function ( ) {
35+ let tag = shallow (
36+ < Image
37+ cloudName = "demo"
38+ publicId = "sample"
39+ variables = { [ [ "$z" , 5 ] , [ "$foo" , "$z * 2" ] ] }
40+ />
41+ ) ;
42+ expect ( tag . type ( ) ) . to . equal ( "img" ) ;
43+ expect ( tag . state ( "url" ) ) . to . equal (
44+ "http://res.cloudinary.com/demo/image/upload/$z_5,$foo_$z_mul_2/sample"
45+ ) ;
46+ } ) ;
47+ it ( "updates transformations dynamically" , function ( ) {
48+ let image = mount (
49+ < Image publicId = "sample" cloudName = "demo" >
50+ < Transformation width = "100" crop = "scale" />
51+ </ Image >
52+ ) ;
53+ expect ( image . find ( 'img' ) . getElement ( ) . props . src ) . to . equal ( 'http://res.cloudinary.com/demo/image/upload/c_scale,w_100/sample' ) ;
54+ let transformation = mount ( < Transformation width = "200" crop = "scale" /> ) ;
55+ image . setProps ( { children : [ transformation ] } ) ;
56+ expect ( image . find ( 'img' ) . getElement ( ) . props . src ) . to . equal ( 'http://res.cloudinary.com/demo/image/upload/c_scale,w_200/sample' ) ;
3157 } ) ;
32- it ( "array should define a set of variables" , function ( ) {
33- let tag = shallow (
34- < Image cloudName = 'demo'
35- publicId = 'sample'
36- variables = { [
37- [ "$z" , 5 ] , [ "$foo" , "$z * 2" ]
38- ] }
39- >
40- </ Image > ) ;
41- expect ( tag . type ( ) ) . to . equal ( "img" ) ;
42- expect ( tag . state ( "url" ) ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/$z_5,$foo_$z_mul_2/sample" ) ;
43- } ) ;
44- } ) ;
58+ } ) ;
0 commit comments