Skip to content

Commit 2edb6c9

Browse files
committed
Update tests to reflect latest changes
1 parent 819b589 commit 2edb6c9

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

test/jsx.js

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function dedent([str]) {
1111
}
1212

1313
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');
1515

1616
it('should render as JSX', () => {
1717
let rendered = renderJsx(
@@ -47,7 +47,15 @@ describe('jsx', () => {
4747
expect(renderJsx(
4848
<a b={false}>bar</a>
4949
)).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>
5159
`);
5260
});
5361

@@ -84,7 +92,7 @@ describe('jsx', () => {
8492
expect(renderJsx(
8593
<a b={<c />}>bar</a>
8694
)).to.equal(dedent`
87-
<a b={<c />}>bar</a>
95+
<a b={<c></c>}>bar</a>
8896
`);
8997

9098
expect(renderJsx(
@@ -96,8 +104,8 @@ describe('jsx', () => {
96104
<a
97105
b={
98106
Array [
99-
<c />,
100-
<d f="g" />
107+
<c></c>,
108+
<d f="g"></d>
101109
]
102110
}
103111
>
@@ -116,12 +124,31 @@ describe('jsx', () => {
116124
</div>
117125
)).to.equal(dedent`
118126
<div>
119-
<a />
120-
<b />
127+
<a></a>
128+
<b></b>
121129
<c>
122130
<!---->
123131
</c>
124132
</div>
125133
`);
126134
});
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+
});
127154
});

0 commit comments

Comments
 (0)