From 60d3d4118406634521018c314415efdb9de7f9c6 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Tue, 28 Jun 2022 15:29:01 +0200 Subject: [PATCH] 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. --- test/hooks/useLatestResult-test.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/hooks/useLatestResult-test.tsx b/test/hooks/useLatestResult-test.tsx index 159c5f3e2f..16a4f20f24 100644 --- a/test/hooks/useLatestResult-test.tsx +++ b/test/hooks/useLatestResult-test.tsx @@ -47,20 +47,20 @@ describe("useLatestResult", () => { await act(async () => { await sleep(25); }); - expect(wrapper.text()).toContain("0"); + expect(wrapper.text()).toEqual("0"); wrapper.setProps({ doRequest, query: 1 }); await act(async () => { - await sleep(15); + await sleep(10); }); wrapper.setProps({ doRequest, query: 2 }); await act(async () => { - await sleep(15); + await sleep(10); }); - expect(wrapper.text()).toContain("0"); + expect(wrapper.text()).toEqual("0"); await act(async () => { await sleep(15); }); - expect(wrapper.text()).toContain("2"); + expect(wrapper.text()).toEqual("2"); }); it("should prevent out-of-order results", async () => { @@ -73,7 +73,7 @@ describe("useLatestResult", () => { await act(async () => { await sleep(5); }); - expect(wrapper.text()).toContain("0"); + expect(wrapper.text()).toEqual("0"); wrapper.setProps({ doRequest, query: 50 }); await act(async () => { await sleep(5); @@ -82,10 +82,10 @@ describe("useLatestResult", () => { await act(async () => { await sleep(5); }); - expect(wrapper.text()).toContain("1"); + expect(wrapper.text()).toEqual("1"); await act(async () => { await sleep(50); }); - expect(wrapper.text()).toContain("1"); + expect(wrapper.text()).toEqual("1"); }); });