Add a larger buffer to useLatestResult's test (#9178)

Should fix https://github.com/vector-im/element-web/issues/23014

With only a 5ms buffer previously it was possible for Jest to get overwhelmed with the 1500 tests it needs to run. We raise this to 20ms to give extra time to settle.

Even with the high sleep times this won't be the longest running test, so should be fine.

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
pull/28217/head
Travis Ralston 2022-08-25 14:49:39 -06:00 committed by GitHub
parent 9b99c967f4
commit e0d5b11bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -40,26 +40,26 @@ function LatestResultsComponent({ query, doRequest }) {
describe("useLatestResult", () => { describe("useLatestResult", () => {
it("should return results", async () => { it("should return results", async () => {
const doRequest = async (query) => { const doRequest = async (query) => {
await sleep(20); await sleep(180);
return query; return query;
}; };
const wrapper = mount(<LatestResultsComponent query={0} doRequest={doRequest} />); const wrapper = mount(<LatestResultsComponent query={0} doRequest={doRequest} />);
await act(async () => { await act(async () => {
await sleep(25); await sleep(100);
}); });
expect(wrapper.text()).toEqual("0"); expect(wrapper.text()).toEqual("0");
wrapper.setProps({ doRequest, query: 1 }); wrapper.setProps({ doRequest, query: 1 });
await act(async () => { await act(async () => {
await sleep(10); await sleep(70);
}); });
wrapper.setProps({ doRequest, query: 2 }); wrapper.setProps({ doRequest, query: 2 });
await act(async () => { await act(async () => {
await sleep(10); await sleep(70);
}); });
expect(wrapper.text()).toEqual("0"); expect(wrapper.text()).toEqual("0");
await act(async () => { await act(async () => {
await sleep(15); await sleep(120);
}); });
expect(wrapper.text()).toEqual("2"); expect(wrapper.text()).toEqual("2");
}); });