Skip to content

Commit 01625aa

Browse files
authored
Merge pull request #59 from lisamartin00/bug/src-empty-string
Default src to undefined instead of empty string
2 parents 3d7c2aa + dc4822f commit 01625aa

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

src/components/Image/Image.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

stories/index.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff 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" })(() => {

test/ImageTest.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff 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
});

0 commit comments

Comments
 (0)