@@ -11,7 +11,7 @@ function dedent([str]) {
11
11
}
12
12
13
13
describe ( 'jsx' , ( ) => {
14
- let renderJsx = jsx => render ( jsx ) . replace ( / { 2 } / g, '\t' ) ;
14
+ let renderJsx = ( jsx , opts ) => render ( jsx , null , opts ) . replace ( / { 2 } / g, '\t' ) ;
15
15
16
16
it ( 'should render as JSX' , ( ) => {
17
17
let rendered = renderJsx (
@@ -47,7 +47,15 @@ describe('jsx', () => {
47
47
expect ( renderJsx (
48
48
< a b = { false } > bar</ a >
49
49
) ) . to . equal ( dedent `
50
- <a b={false}>bar</a>
50
+ <a>bar</a>
51
+ ` ) ;
52
+
53
+ function F ( ) { }
54
+ expect ( renderJsx (
55
+ < F b = { false } > bar</ F > ,
56
+ { shallow :true , renderRootComponent :false }
57
+ ) ) . to . equal ( dedent `
58
+ <F b={false}>bar</F>
51
59
` ) ;
52
60
} ) ;
53
61
@@ -84,7 +92,7 @@ describe('jsx', () => {
84
92
expect ( renderJsx (
85
93
< a b = { < c /> } > bar</ a >
86
94
) ) . to . equal ( dedent `
87
- <a b={<c / >}>bar</a>
95
+ <a b={<c></c >}>bar</a>
88
96
` ) ;
89
97
90
98
expect ( renderJsx (
@@ -96,8 +104,8 @@ describe('jsx', () => {
96
104
<a
97
105
b={
98
106
Array [
99
- <c / >,
100
- <d f="g" / >
107
+ <c></c >,
108
+ <d f="g"></d >
101
109
]
102
110
}
103
111
>
@@ -116,12 +124,31 @@ describe('jsx', () => {
116
124
</ div >
117
125
) ) . to . equal ( dedent `
118
126
<div>
119
- <a / >
120
- <b / >
127
+ <a></a >
128
+ <b></b >
121
129
<c>
122
130
<!---->
123
131
</c>
124
132
</div>
125
133
` ) ;
126
134
} ) ;
135
+
136
+ it ( 'should skip functions if functions=false' , ( ) => {
137
+ expect ( renderJsx (
138
+ < div onClick = { ( ) => { } } /> ,
139
+ { functions :false }
140
+ ) ) . to . equal ( '<div></div>' ) ;
141
+ } ) ;
142
+
143
+ it ( 'should skip function names if functionNames=false' , ( ) => {
144
+ expect ( renderJsx (
145
+ < div onClick = { ( ) => { } } /> ,
146
+ { functionNames :false }
147
+ ) ) . to . equal ( '<div onClick={Function}></div>' ) ;
148
+
149
+ expect ( renderJsx (
150
+ < div onClick = { function foo ( ) { } } /> ,
151
+ { functionNames :false }
152
+ ) ) . to . equal ( '<div onClick={Function}></div>' ) ;
153
+ } ) ;
127
154
} ) ;
0 commit comments