Update Jest to more recent release (#11409)
* Update Jest to more recent release I want to use things like `jest.advanceTimersByTimeAsync` * more jest updates * add dep on types/prettier * fix LegacyRoomHeader-test * fix MatrixChat-test * fix RoomView-test * fix PollHistory-test * update SidebarUserSettingsTab-test * fix PipContainer-test * fix UserOnboardingPage-test * fix WidgetContextMenu-test.tsx * Avoid `mockImplementation` for mock `matchMedia` impl `mockImplementation` is (now) reset by `jest.resetAllMocks` and `jest.restoreAllMocks`, which we don't really want here. Fixes `theme-test` * Move `mediaDevices` mock out of `setupManualMocks` This doesn't work well in test suites with multiple tests, because the `mockReturnValue` is reset for subsequent tests. In any case, having it mocked out automagically is *magical*. Let's make it opt-in. * fix FormattingButtons-test.tsx * fix DeviceListenerTest * fix RoomTile-test
This commit is contained in:
parent
f8e1c54768
commit
7a6d81c3b8
14 changed files with 512 additions and 350 deletions
|
@ -15,8 +15,8 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { Filter, EventTimeline, Room } from "matrix-js-sdk/src/matrix";
|
||||
import { act, fireEvent, render } from "@testing-library/react";
|
||||
import { Filter, EventTimeline, Room, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { M_POLL_START } from "matrix-js-sdk/src/@types/polls";
|
||||
|
||||
import { PollHistory } from "../../../../../src/components/views/polls/pollHistory/PollHistory";
|
||||
|
@ -194,7 +194,11 @@ describe("<PollHistory />", () => {
|
|||
const fourtyDaysAgoTs = now - 60000 * 60 * 24 * 40;
|
||||
const pollStart = makePollStartEvent("Question?", userId, undefined, { ts: fourtyDaysAgoTs, id: "1" });
|
||||
|
||||
jest.spyOn(liveTimeline, "getEvents").mockReset().mockReturnValueOnce([]).mockReturnValueOnce([pollStart]);
|
||||
jest.spyOn(liveTimeline, "getEvents")
|
||||
.mockReset()
|
||||
.mockReturnValueOnce([])
|
||||
.mockReturnValueOnce([pollStart])
|
||||
.mockReturnValue(undefined as unknown as MatrixEvent[]);
|
||||
|
||||
// mock three pages of timeline history
|
||||
jest.spyOn(liveTimeline, "getPaginationToken")
|
||||
|
@ -203,7 +207,7 @@ describe("<PollHistory />", () => {
|
|||
.mockReturnValueOnce("test-pagination-token-3");
|
||||
|
||||
const { getByText } = getComponent();
|
||||
await flushPromises();
|
||||
await act(flushPromises);
|
||||
|
||||
expect(mockClient.paginateEventTimeline).toHaveBeenCalledTimes(1);
|
||||
|
||||
|
@ -216,7 +220,7 @@ describe("<PollHistory />", () => {
|
|||
// load more polls button still in UI, with loader
|
||||
expect(getByText("Load more polls")).toMatchSnapshot();
|
||||
|
||||
await flushPromises();
|
||||
await act(flushPromises);
|
||||
|
||||
// no more spinner
|
||||
expect(getByText("Load more polls")).toMatchSnapshot();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue