Skip to content

Commit

Permalink
refactor: remove melange.belt dependency from the main library
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Oct 20, 2023
1 parent 2499764 commit aadc20d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
35 changes: 14 additions & 21 deletions src/ReactDOM.re
Original file line number Diff line number Diff line change
Expand Up @@ -1736,8 +1736,6 @@ module TestUtils = {
};

module DOM = {
open Belt;

[@mel.return nullable] [@mel.get]
external value: Dom.element => option(string) = "value";

Expand All @@ -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;
};
};
2 changes: 1 addition & 1 deletion test/dune
Original file line number Diff line number Diff line change
Expand Up @@ -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)))

0 comments on commit aadc20d

Please sign in to comment.