Skip to content

Commit

Permalink
feat: support melange v3
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Nov 16, 2023
1 parent 5a1127f commit b0b8d07
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
4 changes: 3 additions & 1 deletion src/ReactDOMTestUtils.re
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ module DOM = {

let findBySelectorAndPartialTextContent = (element, selector, content) =>
querySelectorAll(element, selector)
|> Array.find_opt(node => node->textContent->Js.String2.includes(content));
|> Array.find_opt(node =>
Js.String.includes(~sub=content, node->textContent, ())
);
};

let prepareContainer = (container: ref(option(Dom.element)), ()) => {
Expand Down
15 changes: 7 additions & 8 deletions src/ReasonReactRouter.re
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,22 @@ let pathParse = str =>
| "/" => []
| raw =>
/* remove the preceeding /, which every pathname seems to have */
let raw = Js.String.sliceToEnd(~from=1, raw);
let raw = Js.String.slice(~start=1, raw, ());
/* remove the trailing /, which some pathnames might have. Ugh */
let raw =
switch (Js.String.get(raw, Js.String.length(raw) - 1)) {
| "/" => Js.String.slice(~from=0, ~to_=-1, raw)
| "/" => Js.String.slice(~start=0, ~end_=-1, raw, ())
| _ => raw
};
/* remove search portion if present in string */
let raw =
switch (raw |> Js.String.splitAtMost("?", ~limit=2)) {
switch (Js.String.split(~sep="?", ~limit=2, raw, ())) {
| [|path, _|] => path
| _ => raw
};

raw
|> Js.String.split("/")
|> Js.Array.filter(item => String.length(item) != 0)
Js.String.split(~sep="/", raw, ())
|> Js.Array.filter(~f=item => String.length(item) != 0)
|> arrayToList;
};
let path = (~serverUrlString=?, ()) =>
Expand All @@ -109,15 +108,15 @@ let hash = () =>
| raw =>
/* remove the preceeding #, which every hash seems to have.
Why is this even included in location.hash?? */
raw |> Js.String.sliceToEnd(~from=1)
Js.String.slice(~start=1, raw, ())
}
};
let searchParse = str =>
switch (str) {
| ""
| "?" => ""
| raw =>
switch (raw |> Js.String.splitAtMost("?", ~limit=2)) {
switch (Js.String.split(~sep="?", ~limit=2, raw, ())) {
| [|_, search|] => search
| _ => ""
}
Expand Down
2 changes: 1 addition & 1 deletion test/React__test.re
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ describe("React", () => {
fallback={({error: _, info}) => {
expect(
info.componentStack
->Js.String2.includes("ComponentThatThrows"),
->Js.String.includes(~sub="ComponentThatThrows", ()),
)
->toBe(true);
<strong> "An error occured"->React.string </strong>;
Expand Down

0 comments on commit b0b8d07

Please sign in to comment.