|
5 | 5 | import React, { Fragment, Component } from 'react';
|
6 | 6 | import { createRenderer } from 'react-test-renderer/shallow';
|
7 | 7 | import { mount } from 'enzyme';
|
8 | | -import reactElementToJSXString from './index'; |
| 8 | +import reactElementToJSXString,{preserveFunctionLineBreak} from './index'; |
9 | 9 | import AnonymousStatelessComponent from './AnonymousStatelessComponent';
|
10 | 10 |
|
11 | 11 | class TestComponent extends React.Component {}
|
@@ -889,13 +889,25 @@ describe('reactElementToJSXString(ReactElement)', () => {
|
889 | 889 | reactElementToJSXString(<div fn={fn} />, {
|
890 | 890 | showFunctions: true,
|
891 | 891 | })
|
892 | | - ).toEqual( |
893 | | - `<div |
| 892 | + ).toEqual(`<div fn={function fn() {return 'value';}} />`); |
| 893 | + }); |
| 894 | + |
| 895 | + it('should expose the multiline "functionValue" formatter', () => { |
| 896 | + /* eslint-disable arrow-body-style */ |
| 897 | + const fn = () => { |
| 898 | + return 'value'; |
| 899 | + }; |
| 900 | + |
| 901 | + expect( |
| 902 | + reactElementToJSXString(<div fn={fn} />, { |
| 903 | + showFunctions: true, |
| 904 | + functionValue: preserveFunctionLineBreak, |
| 905 | + }) |
| 906 | + ).toEqual(`<div |
894 | 907 | fn={function fn() {
|
895 | 908 | return 'value';
|
896 | 909 | }}
|
897 | | - />` |
898 | | - ); |
| 910 | + />`); |
899 | 911 | });
|
900 | 912 |
|
901 | 913 | it('reactElementToJSXString(<DisplayNamePrecedence />)', () => {
|
|
0 commit comments