You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-30 02:21:17 +03:00
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.
This commit is contained in:
@ -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");
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user