Updating component mock to handle non-standard attrs

This commit is contained in:
Jeff Avallone 2019-03-24 12:57:09 -04:00
parent babab418c7
commit d813fdf742
2 changed files with 8 additions and 3 deletions

View File

@ -3,7 +3,9 @@ const React = require('react');
const buildMock = component => { const buildMock = component => {
const componentName = component.displayName || component.name || 'Component'; const componentName = component.displayName || component.name || 'Component';
const Mock = ({ children, ...props }) => ( const Mock = ({ children, ...props }) => (
<span data-component={ componentName } { ...props }>{ children }</span> <span
data-component={ componentName }
data-props={ JSON.stringify(props, null, ' ') }>{ children }</span>
); );
Mock.propTypes = component.propTypes; Mock.propTypes = component.propTypes;
return Mock; return Mock;

View File

@ -4,12 +4,15 @@ exports[`SentryError rendering 1`] = `
<DocumentFragment> <DocumentFragment>
<span <span
data-component="Message" data-component="Message"
heading="TRANSLATE(An error has occurred)" data-props="{
type="error" \\"type\\": \\"error\\",
\\"heading\\": \\"TRANSLATE(An error has occurred)\\"
}"
> >
<p> <p>
<span <span
data-component="Trans" data-component="Trans"
data-props="{}"
> >
This error has been logged. You may also This error has been logged. You may also
<a <a