Skip to content

Commit 305e05b

Browse files
author
Thomas Bertet
committed
test(reactElementToJsxString): move owner test case to index.spec.js
1 parent 262221e commit 305e05b

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

src/index.spec.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
/* eslint-disable react/no-string-refs */
44

5-
import React, { Fragment } from 'react';
5+
import React, { Fragment, Component } from 'react';
66
import { createRenderer } from 'react-test-renderer/shallow';
7+
import { mount } from 'enzyme';
78
import reactElementToJSXString from './index';
89
import AnonymousStatelessComponent from './AnonymousStatelessComponent';
910

@@ -1087,4 +1088,29 @@ describe('reactElementToJSXString(ReactElement)', () => {
10871088
)
10881089
).toEqual(`<div render={<><div /><div /></>} />`);
10891090
});
1091+
1092+
it('should not cause recursive loop when prop object contains an element', () => {
1093+
const Test = () => <div>Test</div>;
1094+
1095+
const Container = ({ title: { component } }) => <div>{component}</div>;
1096+
1097+
class App extends Component {
1098+
render() {
1099+
const inside = <Container title={{ component: <Test /> }} />;
1100+
1101+
const insideString = reactElementToJSXString(inside);
1102+
1103+
return (
1104+
<div>
1105+
{insideString}
1106+
1107+
<div id="hello" />
1108+
1109+
<p>Start editing to see some magic happen :)</p>
1110+
</div>
1111+
);
1112+
}
1113+
}
1114+
expect(mount(<App />).find('#hello')).toHaveLength(1);
1115+
});
10901116
});

tests/owner/owner.spec.js

Lines changed: 0 additions & 33 deletions
This file was deleted.

0 commit comments

Comments
 (0)