Skip to content

Commit 87d0033

Browse files
nirmaozNir Maoz
authored andcommitted
Fix video tag props were passed as snake_case instead of camelCase
1 parent 7b50f5e commit 87d0033

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/components/Video/Video.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class Video extends CloudinaryComponent {
7171
const snakeCaseOptions = Util.withSnakeCaseKeys(options);
7272
const cld = Cloudinary.new(snakeCaseOptions);
7373

74-
// Let cloudinary-core handle genrating this video tag attributes
75-
const tagAttributes = cld.videoTag(publicId, snakeCaseOptions).attributes();
74+
// Let cloudinary-core generate this video tag attributes
75+
const tagAttributes = Util.withCamelCaseKeys(cld.videoTag(publicId, options).attributes());
7676

7777
// Aggregate child transformations, used for generating <source> tags for this video element
7878
const childTransformations = this.getTransformation({...options, children});

test/VideoTest.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,29 @@ describe('Video', () => {
166166

167167
expect(tag.props().poster).to.equal('http://res.cloudinary.com/demo/video/upload/c_scale,w_100/dpr_2.0/elephants.jpg');
168168
});
169+
it('Should pass camelCase attributes to Video component', function () {
170+
const tag = shallow(
171+
<Video playsInline autoPlay cloudName='demo' publicId='dog'/>
172+
);
173+
174+
const {autoPlay, auto_play, playsInline, plays_inline} = tag.props();
175+
176+
expect(playsInline).to.equal(true);
177+
expect(autoPlay).to.equal(true);
178+
179+
expect(plays_inline).to.equal(undefined);
180+
expect(auto_play).to.equal(undefined);
181+
});
182+
it('Should pass camelCase attributes to inner video element', function () {
183+
let tag = mount(
184+
<Video playsInline autoPlay cloudName='demo' publicId='dog'/>
185+
);
186+
187+
const video = tag.find('video');
188+
expect(video.prop('playsInline')).to.equal(true);
189+
expect(video.prop('autoPlay')).to.equal(true);
190+
191+
expect(video.prop('plays_inline')).to.equal(undefined);
192+
expect(video.prop('auto_play')).to.equal(undefined);
193+
});
169194
});

0 commit comments

Comments
 (0)