File tree Expand file tree Collapse file tree 3 files changed +23
-2
lines changed
Expand file tree Collapse file tree 3 files changed +23
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ class Image extends CloudinaryComponent {
1515 super ( props , context ) ;
1616 this . handleResize = this . handleResize . bind ( this ) ;
1717
18- let state = { responsive : false , url : "" , breakpoints : defaultBreakpoints } ;
18+ let state = { responsive : false , url : undefined , breakpoints : defaultBreakpoints } ;
1919 this . state = Object . assign ( state , this . prepareState ( props , context ) ) ;
2020 }
2121
Original file line number Diff line number Diff line change @@ -61,6 +61,23 @@ storiesOf("Image", module)
6161 ) ;
6262 } )
6363 )
64+ . add (
65+ "responsive image with width/height styles applied" ,
66+ withInfo ( { text : "Basic tag" } ) ( ( ) => {
67+ return (
68+ < div style = { { width : '50%' } } >
69+ < Image
70+ style = { { width : '100%' , height : '100%' } }
71+ cloudName = "demo"
72+ publicId = "sample"
73+ crop = "scale"
74+ width = "auto"
75+ responsive
76+ />
77+ </ div >
78+ )
79+ } )
80+ )
6481 . add (
6582 "image with alt" ,
6683 withInfo ( { text : "Demostrate using an img tag attribute" } ) ( ( ) => {
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ describe('Image', () => {
3232 let tag2 = mount ( < div width = "300" > < Image publicId = "sample" cloudName = "demo" width = "auto" crop = "scale" privateCdn = "private" defaultImage = "foobar" responsive responsiveUseBreakpoints /> </ div > ) ;
3333 let tag = shallow ( < Image publicId = "sample" cloudName = "demo" width = "auto" crop = "scale" privateCdn = "private" defaultImage = "foobar" responsive responsiveUseBreakpoints /> ) ;
3434 expect ( tag . type ( ) ) . to . equal ( "img" ) ;
35- expect ( tag . state ( "url" ) ) . to . equal ( "" ) ;
35+ expect ( tag . state ( "url" ) ) . to . equal ( undefined ) ;
3636 expect ( tag . props ( ) ) . to . have . property ( 'src' ) ;
3737
3838 // We are checking for both snake_case and camelCase keys
@@ -65,4 +65,8 @@ describe('Image', () => {
6565 tag . setState ( { cyclicProp : obj1 } ) ;
6666 tag . setState ( { cyclicProp : obj2 } ) ;
6767 } ) ;
68+ it ( "should render a src property with an undefined value if a src is not defined" , function ( ) {
69+ let tag = mount ( < Image cloudName = "demo" /> ) ;
70+ expect ( tag . find ( 'img' ) . prop ( 'src' ) ) . to . equal ( undefined ) ;
71+ } ) ;
6872} ) ;
You can’t perform that action at this time.
0 commit comments