Skip to content

Commit

Permalink
fix: test function returns false if value is undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
keplersj committed Aug 20, 2019
1 parent d5886c4 commit 4fb981d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
6 changes: 6 additions & 0 deletions src/index.test.tsx
Expand Up @@ -33,6 +33,12 @@ describe("Serializer test function", () => {

expect(shouldSerialize).toEqual(false);
});

it("returns false if value is undefined", () => {
const shouldSerialize = serializer.test(undefined);

expect(shouldSerialize).toEqual(false);
});
});

describe("Serialization function", () => {
Expand Down
12 changes: 6 additions & 6 deletions src/index.tsx
Expand Up @@ -2,13 +2,13 @@ import * as React from "react";

const JSONLDSerializer: jest.SnapshotSerializerPlugin = {
test(val) {
return (
return Boolean(
val &&
val.$$typeof === Symbol.for("react.element") &&
val.type === "script" &&
val.props.dangerouslySetInnerHTML &&
val.props.type &&
val.props.type === "application/ld+json"
val.$$typeof === Symbol.for("react.element") &&
val.type === "script" &&
val.props.dangerouslySetInnerHTML &&
val.props.type &&
val.props.type === "application/ld+json"
);
},

Expand Down

0 comments on commit 4fb981d

Please sign in to comment.