File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
src/components/CloudinaryContext Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change 1313 - TEST_SUBJECT=src
1414 - TEST_SUBJECT=lib
1515 - TEST_SUBJECT=dist
16+ matrix :
17+ exclude :
18+ - node_js : 6
19+ env : TEST_SUBJECT=src
Original file line number Diff line number Diff line change 11import React from 'react' ;
2+ import PropTypes from 'prop-types' ;
23import CloudinaryComponent from '../CloudinaryComponent' ;
34import { Util } from 'cloudinary-core' ;
45
@@ -40,7 +41,9 @@ class CloudinaryContext extends CloudinaryComponent {
4041 allowedProps [ currentProp ] = this . props [ currentProp ] ;
4142 return allowedProps ;
4243 } , { } ) ;
43- return < div { ...nonCloudinaryProps } > { this . props . children } </ div > ;
44+ const { includeOwnBody, ...props } = nonCloudinaryProps ;
45+
46+ return includeOwnBody ? this . props . children : < div { ...props } > { this . props . children } </ div > ;
4447 }
4548}
4649
@@ -53,8 +56,8 @@ CloudinaryContext.CLOUDINARY_PROPS = CloudinaryComponent.VALID_OPTIONS.reduce(
5356 { }
5457) ;
5558
56- CloudinaryContext . propTypes = CloudinaryComponent . propTypes ;
57- CloudinaryContext . defaultProps = { } ;
59+ CloudinaryContext . propTypes = { ... CloudinaryComponent . propTypes , includeOwnBody : PropTypes . bool } ;
60+ CloudinaryContext . defaultProps = { includeOwnBody : false } ;
5861CloudinaryContext . childContextTypes = CloudinaryComponent . contextTypes ;
5962
6063export default CloudinaryContext ;
Original file line number Diff line number Diff line change @@ -19,6 +19,25 @@ describe('CloudinaryContext', () => {
1919 expect ( img . instance ( ) . state . url ) . to . equal ( "http://res.cloudinary.com/demo/image/upload/sample" ) ;
2020 } ) ;
2121
22+ it ( "should render without div" , function ( ) {
23+ let tag = mount (
24+ < CloudinaryContext className = "root" cloudName = "demo" includeOwnBody = { true } >
25+ < Image publicId = "sample" />
26+ </ CloudinaryContext >
27+ ) ;
28+
29+ expect ( tag . html ( ) . startsWith ( "<div" ) ) . to . equal ( false ) ;
30+ } ) ;
31+ it ( "should render with div" , function ( ) {
32+ let tag = mount (
33+ < CloudinaryContext className = "root" cloudName = "demo" includeOwnBody = { false } >
34+ < Image publicId = "sample" />
35+ </ CloudinaryContext >
36+ ) ;
37+
38+ expect ( tag . html ( ) . startsWith ( "<div" ) ) . to . equal ( true ) ;
39+ } ) ;
40+
2241 it ( "should pass properties to children with snake case" , function ( ) {
2342 let tag = mount (
2443 < CloudinaryContext className = "root" cloudName = "demo" fetch_format = "auto" >
You can’t perform that action at this time.
0 commit comments