1
1
import _ from 'lodash'
2
- import React , { createElement } from 'react'
2
+ import React from 'react'
3
3
4
4
import { consoleUtil } from 'test/utils'
5
5
@@ -8,24 +8,24 @@ export const classNamePropValueBeforePropName = (Component, propKey, propValues,
8
8
9
9
propValues . forEach ( ( propVal ) => {
10
10
it ( `adds "${ propVal } ${ className } " to className` , ( ) => {
11
- shallow ( createElement ( Component , { ...requiredProps , [ propKey ] : propVal } ) , {
12
- autoNesting : true ,
13
- } ) . should . have . className ( `${ propVal } ${ className } ` )
11
+ const wrapper = mount (
12
+ React . createElement ( Component , { ...requiredProps , [ propKey ] : propVal } ) ,
13
+ )
14
+ const elementClassName = wrapper . childAt ( 0 ) . getDOMNode ( ) . className
15
+
16
+ expect ( elementClassName ) . include ( `${ propVal } ${ className } ` )
14
17
} )
15
18
} )
16
19
}
17
20
18
21
export const noClassNameFromBoolProps = ( Component , propKey , propValues , options = { } ) => {
19
- const { className = propKey , nestingLevel = 0 , requiredProps = { } } = options
22
+ const { className = propKey , requiredProps = { } } = options
20
23
21
24
_ . each ( [ true , false ] , ( bool ) =>
22
25
it ( `does not add any className when ${ bool } ` , ( ) => {
23
26
consoleUtil . disableOnce ( )
24
27
25
- const wrapper = shallow ( createElement ( Component , { ...requiredProps , [ propKey ] : bool } ) , {
26
- autoNesting : true ,
27
- nestingLevel,
28
- } )
28
+ const wrapper = mount ( React . createElement ( Component , { ...requiredProps , [ propKey ] : bool } ) )
29
29
30
30
wrapper . should . not . have . className ( className )
31
31
wrapper . should . not . have . className ( 'true' )
@@ -38,15 +38,18 @@ export const noClassNameFromBoolProps = (Component, propKey, propValues, options
38
38
39
39
export const noDefaultClassNameFromProp = ( Component , propKey , propValues , options = { } ) => {
40
40
const { defaultProps = { } } = Component
41
- const { className = propKey , nestingLevel = 0 , requiredProps = { } } = options
41
+ const { className = propKey , requiredProps = { } } = options
42
+
42
43
// required props may include a prop that creates a className
43
44
// if so, we cannot assert that it doesn't exist by default because it is required to exist
44
45
// skip assertions for required props
45
46
if ( propKey in defaultProps ) return
46
47
if ( propKey in requiredProps ) return
47
48
48
49
it ( 'is not included in className when not defined' , ( ) => {
49
- const wrapper = shallow ( < Component { ...requiredProps } /> , { autoNesting : true , nestingLevel } )
50
+ consoleUtil . disableOnce ( )
51
+ const wrapper = mount ( < Component { ...requiredProps } /> )
52
+
50
53
wrapper . should . not . have . className ( className )
51
54
52
55
// ensure that none of the prop option values are in className
0 commit comments