@@ -29,11 +29,16 @@ describe('Conformance', () => {
2929 } ) ;
3030
3131 it ( `has the "${ sdClass } " element as its first child (no wrapper elements)` , ( ) => {
32- expect ( firstChild . props . className ) . to . contain ( sdClass ) ;
32+ if ( isDOMComponent ( firstChild ) ) {
33+ expect ( firstChild . getAttribute ( 'class' ) ) . to . contain ( sdClass ) ;
34+ } else {
35+ expect ( firstChild . props . className ) . to . contain ( sdClass ) ;
36+ }
3337 } ) ;
3438
3539 describe ( '_meta' , ( ) => {
36- const _meta = _ . get ( SDComponent , '_meta' ) ;
40+ const _meta = SDComponent . _meta ;
41+
3742 it ( 'is a static object prop' , ( ) => {
3843 expect ( _meta ) . to . be . an ( 'object' ) ;
3944 } ) ;
@@ -74,29 +79,32 @@ describe('Conformance', () => {
7479 describe ( 'props' , ( ) => {
7580 it ( 'spreads props' , ( ) => {
7681 const props = { } ;
77- _ . times ( 2 , ( ) => {
78- // single word props
79- props [ faker . hacker . noun ( ) ] = faker . hacker . noun ( ) ;
80- // camelCased props
81- props [ _ . camelCase ( faker . hacker . phrase ( ) ) ] = faker . hacker . phrase ( ) ;
82- // kebab-cased props
83- props [ _ . kebabCase ( faker . hacker . phrase ( ) ) ] = faker . hacker . phrase ( ) ;
84- } ) ;
82+ // JSX does not render custom html attributes so we prefix them with data-*.
83+ // https://facebook.github.io/react/docs/jsx-gotchas.html#custom-html-attributes
84+ props [ `data-${ faker . hacker . noun ( ) } ` ] = faker . hacker . noun ( ) ;
8585
8686 // create element with random props
87- const componentWithProps = < SDComponent { ...props } /> ;
88-
89- const hasSpreadProps = render ( componentWithProps )
87+ render ( < SDComponent { ...props } /> )
9088 . children ( )
91- . some ( element => _ . every ( [ element . props ] , props ) ) ;
92-
93- hasSpreadProps . should . equal ( true ) ;
89+ . some ( child => {
90+ return _ . every ( props , ( val , key ) => {
91+ return isDOMComponent ( child )
92+ ? child . getAttribute ( key ) === val
93+ : child . props [ key ] === val ;
94+ } ) ;
95+ } )
96+ . should . equal ( true ) ;
9497 } ) ;
9598 describe ( 'className' , ( ) => {
9699 it ( `has props.className after "${ sdClass } "` , ( ) => {
97- const renderedClasses = render ( < SDComponent className = { classes } /> )
98- . findClass ( sdClass )
99- . props . className ;
100+ let renderedClasses ;
101+ const rendered = render ( < SDComponent className = { classes } /> )
102+ . findClass ( sdClass ) ;
103+ if ( isDOMComponent ( rendered ) ) {
104+ renderedClasses = rendered . getAttribute ( 'class' ) ;
105+ } else {
106+ renderedClasses = rendered . props . className ;
107+ }
100108 const sdClassIndex = renderedClasses . indexOf ( sdClass ) ;
101109 const classesIndex = renderedClasses . indexOf ( classes ) ;
102110 expect ( sdClassIndex ) . to . be . below ( classesIndex ) ;
0 commit comments