| 1 | // `test` is part of Jest's serializer API |
| 2 | export function test(maybeInspectedElement) { |
| 3 | if ( |
| 4 | maybeInspectedElement === null || |
| 5 | typeof maybeInspectedElement !== 'object' |
| 6 | ) { |
| 7 | return false; |
| 8 | } |
| 9 | |
| 10 | const hasOwnProperty = Object.prototype.hasOwnProperty.bind( |
| 11 | maybeInspectedElement, |
| 12 | ); |
| 13 | |
| 14 | return ( |
| 15 | hasOwnProperty('canEditFunctionProps') && |
| 16 | hasOwnProperty('canEditHooks') && |
| 17 | hasOwnProperty('canToggleSuspense') && |
| 18 | hasOwnProperty('canToggleError') |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | // print() is part of Jest's serializer API |
| 23 | export function print(inspectedElement, serialize, indent) { |
| 24 | // Don't stringify this object; that would break nested serializers. |
| 25 | return serialize({ |
| 26 | context: inspectedElement.context, |
| 27 | events: inspectedElement.events, |
| 28 | hooks: inspectedElement.hooks, |
| 29 | id: inspectedElement.id, |
| 30 | owners: inspectedElement.owners, |
| 31 | props: inspectedElement.props, |
| 32 | rootType: inspectedElement.rootType, |
| 33 | state: inspectedElement.state, |
| 34 | }); |
| 35 | } |