From e706a6d8597df8958f55e4704fa39b5db4cbe7be Mon Sep 17 00:00:00 2001 From: Antonio Nuno Monteiro Date: Fri, 20 Oct 2023 00:22:59 -0700 Subject: [PATCH] refactor: remove `melange.belt` dependency from the main library (#801) --- src/ReactDOM.re | 35 ++++++++++++++--------------------- test/dune | 2 +- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/ReactDOM.re b/src/ReactDOM.re index a54827322..03f2a841c 100644 --- a/src/ReactDOM.re +++ b/src/ReactDOM.re @@ -1736,8 +1736,6 @@ module TestUtils = { }; module DOM = { - open Belt; - [@mel.return nullable] [@mel.get] external value: Dom.element => option(string) = "value"; @@ -1749,36 +1747,31 @@ module TestUtils = { let findBySelectorAndTextContent = (element, selector, content) => querySelectorAll(element, selector) - ->Array.getBy(node => node->textContent === content); + |> Array.find_opt(node => node->textContent === content); let findBySelectorAndPartialTextContent = (element, selector, content) => querySelectorAll(element, selector) - ->Array.getBy(node => node->textContent->Js.String2.includes(content)); + |> Array.find_opt(node => + node->textContent->Js.String2.includes(content) + ); }; let prepareContainer = (container: ref(option(Dom.element)), ()) => { - Belt.( - { - let containerElement = document->createElement("div"); - let _ = - document - ->body - ->Option.map(body => body->appendChild(containerElement)); - container := Some(containerElement); - } - ); + let containerElement = document->createElement("div"); + let _: option(_) = + Option.map( + body => body->appendChild(containerElement), + document->body, + ); + container := Some(containerElement); }; let cleanupContainer = (container: ref(option(Dom.element)), ()) => { - Belt.( - { - let _ = container.contents->Option.map(remove); - container := None; - } - ); + let _: option(_) = Option.map(remove, container^); + container := None; }; let getContainer = container => { - Belt.(container.contents->Option.getExn); + container.contents->Option.get; }; }; diff --git a/test/dune b/test/dune index 60b26f091..c595839ce 100644 --- a/test/dune +++ b/test/dune @@ -3,6 +3,6 @@ (target test) (module_systems (commonjs bs.js)) - (libraries reason-react jest) + (libraries reason-react jest melange.belt) (preprocess (pps melange.ppx reason-react-ppx)))