forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinspectedElementSerializer.js
More file actions
34 lines (32 loc) · 978 Bytes
/
inspectedElementSerializer.js
File metadata and controls
34 lines (32 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// test() is part of Jest's serializer API
export function test(maybeInspectedElement) {
if (
maybeInspectedElement === null ||
typeof maybeInspectedElement !== 'object'
) {
return false;
}
const hasOwnProperty = Object.prototype.hasOwnProperty.bind(
maybeInspectedElement,
);
return (
hasOwnProperty('canEditFunctionProps') &&
hasOwnProperty('canEditHooks') &&
hasOwnProperty('canToggleSuspense') &&
hasOwnProperty('canToggleError') &&
hasOwnProperty('canViewSource')
);
}
// print() is part of Jest's serializer API
export function print(inspectedElement, serialize, indent) {
// Don't stringify this object; that would break nested serializers.
return serialize({
context: inspectedElement.context,
events: inspectedElement.events,
hooks: inspectedElement.hooks,
id: inspectedElement.id,
owners: inspectedElement.owners,
props: inspectedElement.props,
state: inspectedElement.state,
});
}