From 7ca0f2e6440d2ff8db526c712df5e9a937ac0450 Mon Sep 17 00:00:00 2001 From: Javier Chavarri Date: Fri, 20 Oct 2023 06:14:20 +0000 Subject: [PATCH 1/2] testrenderer: add toObject --- src/ReactTestRenderer.re | 1 + src/ReactTestRenderer.rei | 1 + test/ReactTestRenderer__test.re | 4 +--- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ReactTestRenderer.re b/src/ReactTestRenderer.re index e5b4588bf..7555541f6 100644 --- a/src/ReactTestRenderer.re +++ b/src/ReactTestRenderer.re @@ -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; diff --git a/src/ReactTestRenderer.rei b/src/ReactTestRenderer.rei index ed7c0ebce..1e91c3160 100644 --- a/src/ReactTestRenderer.rei +++ b/src/ReactTestRenderer.rei @@ -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; diff --git a/test/ReactTestRenderer__test.re b/test/ReactTestRenderer__test.re index 2324b1dd9..2db87305d 100644 --- a/test/ReactTestRenderer__test.re +++ b/test/ReactTestRenderer__test.re @@ -1,7 +1,5 @@ open Jest; -external toObject: ReactTestRenderer.t => Js.t({.}) = "%identity"; - module Tester = { [@react.component] let make = () =>
{React.string("Tester")}
; @@ -12,7 +10,7 @@ describe("ReactTestRenderer", () => { test("create returns ReactTestInstance", () => { let component = ReactTestRenderer.create(); - let keys = Js.Obj.keys(Obj.magic(component): Js.t({..})); + let keys = Js.Obj.keys(ReactTestRenderer.toObject(component)); expect(keys) ->toEqual( From 4940103d09579c11b669725e9b9d5ec881b6386f Mon Sep 17 00:00:00 2001 From: Javier Chavarri Date: Fri, 20 Oct 2023 07:57:23 +0000 Subject: [PATCH 2/2] fix toObject type --- src/ReactTestRenderer.re | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ReactTestRenderer.re b/src/ReactTestRenderer.re index 7555541f6..2c3494447 100644 --- a/src/ReactTestRenderer.re +++ b/src/ReactTestRenderer.re @@ -4,7 +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"; +[@mel.send] external toObject: t => Js.t({..}) = "%identity"; module Shallow = { type t;