mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08: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:
parent
7f7ad10b04
commit
60d3d41184
@ -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");
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user