Skip to content

Commit

Permalink
Use same pattern in custom snapshot serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Apr 25, 2021
1 parent ee699c0 commit 56fcc69
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ 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 = Object.prototype.hasOwnProperty.bind(maybeState);
// Duck typing at its finest.
return (
maybeState !== null &&
typeof maybeState === 'object' &&
hasOwnProperty('inspectedElementID') &&
hasOwnProperty('ownerFlatTree') &&
hasOwnProperty('ownerSubtreeLeafElementID')
Expand Down

0 comments on commit 56fcc69

Please sign in to comment.