Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit 1e4cd6c

Browse files
authored
Change type of cleanup function (#23)
1 parent 12e7874 commit 1e4cd6c

File tree

5 files changed

+31
-12
lines changed

5 files changed

+31
-12
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ jobs:
2020
deno-version: '0.40'
2121
- run: yarn install --frozen-lockfile
2222
- run: yarn --check-files
23-
- run: deno run --allow-read --allow-write https://denopkg.com/wyze/conditional_bisect@v1.0.0/mod.ts
23+
- run: deno run --allow-read --allow-write https://denopkg.com/wyze/conditional_bisect@v1.0.1/mod.ts
2424
- run: yarn test:coverage
2525
- run: yarn bisect-ppx-report send-to Codecov

src/ReactTestingLibrary.re

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type renderOptions = {
1616
};
1717

1818
[@bs.module "@testing-library/react"]
19-
external cleanup: unit => unit = "cleanup";
19+
external cleanup: unit => Js.Promise.t(unit) = "cleanup";
2020

2121
[@bs.module "@testing-library/react"]
2222
external _act: (unit => Js.undefined(Js.Promise.t('a))) => unit = "act";

src/ReactTestingLibrary.rei

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ type renderOptions = {
8484
};
8585

8686
[@bs.module "@testing-library/react"]
87-
external cleanup: unit => unit = "cleanup";
87+
external cleanup: unit => Js.Promise.t(unit) = "cleanup";
8888

8989
let act: (unit => unit) => unit;
9090

src/__tests__/ReactTestingLibrary_test.re

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@ module Counter = {
1616

1717
[@react.component]
1818
let make = () => {
19-
let (state, dispatch) = React.useReducer(
20-
(state, action) =>
21-
switch (action) {
22-
| Inc => state + 1
23-
| Dec => state - 1
24-
},
25-
0
26-
);
19+
let (state, dispatch) =
20+
React.useReducer(
21+
(state, action) =>
22+
switch (action) {
23+
| Inc => state + 1
24+
| Dec => state - 1
25+
},
26+
0,
27+
);
2728

2829
<div>
2930
{ReasonReact.string("Count: " ++ string_of_int(state))}
@@ -33,7 +34,7 @@ module Counter = {
3334
<button onClick={_event => dispatch(Dec)}>
3435
{ReasonReact.string("-")}
3536
</button>
36-
</div>
37+
</div>;
3738
};
3839
};
3940

@@ -685,4 +686,20 @@ describe("ReactTestingLibrary", () => {
685686
|> expect
686687
|> toMatchSnapshot;
687688
});
689+
690+
testPromise("Cleaunp, (element not found)", () => {
691+
let result = element |> render;
692+
693+
cleanup()
694+
|> Js.Promise.(
695+
then_(_ => {
696+
Js.Promise.resolve(
697+
result
698+
|> queryByTestId(~matcher=`Str("h1-heading"))
699+
|> expect
700+
|> toMatchSnapshot,
701+
)
702+
})
703+
);
704+
});
688705
});

src/__tests__/__snapshots__/ReactTestingLibrary_test.bs.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,8 @@ exports[`ReactTestingLibrary ByTitle queryByTitle works 1`] = `
400400
/>
401401
`;
402402

403+
exports[`ReactTestingLibrary Cleaunp, (element not found) 1`] = `null`;
404+
403405
exports[`ReactTestingLibrary act works 1`] = `
404406
<div>
405407
Count: 1

0 commit comments

Comments
 (0)