Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
,
{}} />,
,
,
,
,
,
,
,
,
];
/* eslint-enable react/jsx-key, react-native/no-inline-styles */
for ( const root of snapshotTests ) {
test(ToJSX(root, {maxInlineAttributesLineLength: Infinity}), () => {
const host = ReactTestRenderer.create(
{root}
);
expect(host.toJSON()).toMatchSnapshot();
});
}
test(" to have measure methods", () => {
let instance;
ReactTestRenderer.create(
instance = ref} />
);
const renderElementToJSX = (element: React.ReactNode, triggerErrorOnRenderFn: boolean = false) => {
let renderHasFunction
const jsxMarkup = reactElementToJSXString(element, {
displayName: (element: React.ReactElement): string => {
const displayName = getDisplayName(element)
// Components created by MDX have following signature:
//
return displayName === 'MDXCreateElement' ? element.props.mdxType : displayName
},
showDefaultProps: false,
showFunctions: true,
filterProps: [
// MDX props
'mdxType',
'originalType',
// Stardust props
'accessibility',
'onClick',
function stringifyValue(key: string, value: mixed): FixtureStateValue {
try {
// NOTE: Is this optimal?
if (!isEqual(JSON.parse(JSON.stringify(value)), value)) {
throw new Error('Unserializable value');
}
} catch (err) {
return {
serializable: false,
key,
// TODO: Enable custom stringifiers to plug in
stringified: isElement(value)
? // $FlowFixMe No static way to show that value is React.Element
reactElementToJSXString(value)
: String(value)
};
}
return {
serializable: true,
key,
stringified: JSON.stringify(value)
};
}
const JsxHighlight = ({ component }) => {
let code =
typeof component === 'function'
? reactElementToJSXString(component(), {
// displayName: () => component.displayName,
})
: component;
code = normalizeJSX(code);
return (
{({ renderCopier }) => (
{renderCopier({
text:
typeof component === 'function'
? code
: JSON.stringify(code, null, 2),
})}
render() {
let { children: source } = this.props;
if (typeof source === "object") {
// $FlowFixMe
source = elementToString(source, { showDefaultProps: false, showFunctions: true });
} else {
source = String(source);
}
return (
{this.props.copy && (
<div> this.copy(source)} className="container">
{this.state.copied ? (
<span>Copied!</span>
) : (
<span>Copy</span>
)}
</div>
)}
getCode: () => {
let code: string
try {
code = toString(children, TO_STRING_OPTIONS)
} catch (e) {
code = `/* Error: ${e.message} */`
}
return code
}
})
toIncludeJSX(ReactElement) {
return expect(
collapse(reactElementToJSXString(this.actual))
).toInclude(
collapse(reactElementToJSXString(ReactElement))
);
},
toNotIncludeJSX(ReactElement) {