Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: reasonml/reason-react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2d608830d08178fad9711dfa6eb2bea3e2d98b8e
Choose a base ref
..
head repository: reasonml/reason-react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 15e0877427668c775f47ea6cecc9890c5a9712d6
Choose a head ref
Showing with 13 additions and 22 deletions.
  1. +13 −22 test/React__test.re
35 changes: 13 additions & 22 deletions test/React__test.re
Original file line number Diff line number Diff line change
@@ -257,35 +257,26 @@ describe("React", () => {
let make = () => {
let (count, setCount) = React.Uncurried.useState(() => 0);

React.useEffect1(
() => {
document->setTitle(
"You clicked " ++ Int.to_string(count) ++ " times",
);
None;
},
[|count|],
);

<div>
<button role="Increment" onClick={_ => setCount(. prev => prev + 1)}>
<button
className="Increment" onClick={_ => setCount(. prev => prev + 1)}>
{React.string("Increment")}
</button>
<span role="counter"> {React.string(string_of_int(count))} </span>
<span className="Value"> {React.string(string_of_int(count))} </span>
</div>;
};
};

testPromise("act", finish => {
let containerRef: ref(Js.nullable(ReactTestingLibrary.renderResult)) =
ref(Js.Nullable.null);

let.await _ =
React.act(() => {
let container = ReactTestingLibrary.render(<Counter />);
let button = getByRole("Increment", container);
FireEvent.click(button);
containerRef.contents = Js.Nullable.return(container);
});

switch (Js.Nullable.toOption(containerRef.contents)) {
| Some(container) =>
expect(getByRole("counter", container)->innerHTML)->toBe("1")
| None => failwith("Container is null")
};
finish();
});

testPromise("act", finish => {
/* This test doesn't use ReactTestingLibrary to test the act API, and the code comes from
https://react.dev/reference/react/act example */