Skip to content

Commit

Permalink
testrenderer: add toObject (#802)
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavarri authored Oct 20, 2023
1 parent c36c9d0 commit 1391d6c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/ReactTestRenderer.re
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type t;
external create: React.element => t = "create";

[@mel.send] external toJSON: t => Js.Json.t = "toJSON";
[@mel.send] external toObject: t => Js.t({..}) = "%identity";

module Shallow = {
type t;
Expand Down
1 change: 1 addition & 0 deletions src/ReactTestRenderer.rei
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ type t;
external create: React.element => t = "create";

[@mel.send] external toJSON: t => Js.Json.t = "toJSON";
[@mel.send] external toObject: t => Js.t({.}) = "%identity";

module Shallow: {
type t;
Expand Down
4 changes: 1 addition & 3 deletions test/ReactTestRenderer__test.re
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
open Jest;

external toObject: ReactTestRenderer.t => Js.t({.}) = "%identity";

module Tester = {
[@react.component]
let make = () => <div> {React.string("Tester")} </div>;
Expand All @@ -12,7 +10,7 @@ describe("ReactTestRenderer", () => {

test("create returns ReactTestInstance", () => {
let component = ReactTestRenderer.create(<Tester />);
let keys = Js.Obj.keys(Obj.magic(component): Js.t({..}));
let keys = Js.Obj.keys(ReactTestRenderer.toObject(component));

expect(keys)
->toEqual(
Expand Down

0 comments on commit 1391d6c

Please sign in to comment.