Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 60d3d41

Browse files
authored
Improve timing safety of useLatestResult test (#8915)
and fix contains to be equals instead, as it's *possible* we can accidentally punch in 20 or something and still have the test pass.
1 parent 7f7ad10 commit 60d3d41

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/hooks/useLatestResult-test.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ describe("useLatestResult", () => {
4747
await act(async () => {
4848
await sleep(25);
4949
});
50-
expect(wrapper.text()).toContain("0");
50+
expect(wrapper.text()).toEqual("0");
5151
wrapper.setProps({ doRequest, query: 1 });
5252
await act(async () => {
53-
await sleep(15);
53+
await sleep(10);
5454
});
5555
wrapper.setProps({ doRequest, query: 2 });
5656
await act(async () => {
57-
await sleep(15);
57+
await sleep(10);
5858
});
59-
expect(wrapper.text()).toContain("0");
59+
expect(wrapper.text()).toEqual("0");
6060
await act(async () => {
6161
await sleep(15);
6262
});
63-
expect(wrapper.text()).toContain("2");
63+
expect(wrapper.text()).toEqual("2");
6464
});
6565

6666
it("should prevent out-of-order results", async () => {
@@ -73,7 +73,7 @@ describe("useLatestResult", () => {
7373
await act(async () => {
7474
await sleep(5);
7575
});
76-
expect(wrapper.text()).toContain("0");
76+
expect(wrapper.text()).toEqual("0");
7777
wrapper.setProps({ doRequest, query: 50 });
7878
await act(async () => {
7979
await sleep(5);
@@ -82,10 +82,10 @@ describe("useLatestResult", () => {
8282
await act(async () => {
8383
await sleep(5);
8484
});
85-
expect(wrapper.text()).toContain("1");
85+
expect(wrapper.text()).toEqual("1");
8686
await act(async () => {
8787
await sleep(50);
8888
});
89-
expect(wrapper.text()).toContain("1");
89+
expect(wrapper.text()).toEqual("1");
9090
});
9191
});

0 commit comments

Comments
 (0)