19 lines
No EOL
857 B
JavaScript
19 lines
No EOL
857 B
JavaScript
import { printStore } from 'react-devtools-shared/src/devtools/utils';
|
|
|
|
// test() is part of Jest's serializer API
|
|
export function test(maybeState) {
|
|
if (maybeState === null || typeof maybeState !== 'object') {
|
|
return false;
|
|
}
|
|
const hasOwnProperty = maybeState |> Object.prototype.hasOwnProperty.bind(%);
|
|
// Duck typing at its finest.
|
|
return ('inspectedElementID' |> hasOwnProperty(%)) && ('ownerFlatTree' |> hasOwnProperty(%)) && ('ownerSubtreeLeafElementID' |> hasOwnProperty(%));
|
|
}
|
|
|
|
// print() is part of Jest's serializer API
|
|
export function print(state, serialize, indent) {
|
|
// This is a big of a hack but it works around having to pass in a meta object e.g. {store, state}.
|
|
// DevTools tests depend on a global Store object anyway (initialized via setupTest).
|
|
const store = global.store;
|
|
return printStore(store, false, state);
|
|
} |