Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove melange.belt dependency from the main library #801

Merged
merged 1 commit into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)))
Loading