convert test-utils to typescript (#7877)
* move js utils into directory Signed-off-by: Kerry Archibald <kerrya@element.io> * typescripterize js test-utils Signed-off-by: Kerry Archibald <kerrya@element.io> * move test utils to directory Signed-off-by: Kerry Archibald <kerrya@element.io> * move remaining mock functions to directory Signed-off-by: Kerry Archibald <kerrya@element.io> * update imports Signed-off-by: Kerry Archibald <kerrya@element.io> * missed copyright Signed-off-by: Kerry Archibald <kerrya@element.io> * type wait for update Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
93a9af7b3a
commit
5e76d988ca
13 changed files with 269 additions and 201 deletions
|
@ -23,7 +23,7 @@ import { act } from 'react-dom/test-utils';
|
|||
import '../../../skinned-sdk';
|
||||
import SpaceContextMenu from '../../../../src/components/views/context_menus/SpaceContextMenu';
|
||||
import MatrixClientContext from '../../../../src/contexts/MatrixClientContext';
|
||||
import { findByTestId } from '../../../utils/test-utils';
|
||||
import { findByTestId } from '../../../test-utils';
|
||||
import {
|
||||
leaveSpace,
|
||||
shouldShowSpaceSettings,
|
||||
|
|
|
@ -21,7 +21,7 @@ import { act } from 'react-dom/test-utils';
|
|||
import sdk from '../../../skinned-sdk';
|
||||
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
|
||||
import { stubClient } from '../../../test-utils';
|
||||
import { findById, flushPromises } from '../../../utils/test-utils';
|
||||
import { findById, flushPromises } from '../../../test-utils';
|
||||
|
||||
const AccessSecretStorageDialog = sdk.getComponent("dialogs.security.AccessSecretStorageDialog");
|
||||
|
||||
|
|
|
@ -28,11 +28,14 @@ import {
|
|||
} from 'matrix-events-sdk';
|
||||
import { IContent, MatrixEvent } from 'matrix-js-sdk/src/models/event';
|
||||
|
||||
import * as TestUtils from "../../../test-utils";
|
||||
import { findById } from '../../../utils/test-utils';
|
||||
import {
|
||||
wrapInMatrixClientContext,
|
||||
findById,
|
||||
stubClient,
|
||||
} from '../../../test-utils';
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import _PollCreateDialog from "../../../../src/components/views/elements/PollCreateDialog";
|
||||
const PollCreateDialog = TestUtils.wrapInMatrixClientContext(_PollCreateDialog);
|
||||
const PollCreateDialog = wrapInMatrixClientContext(_PollCreateDialog);
|
||||
|
||||
// Fake date to give a predictable snapshot
|
||||
const realDateNow = Date.now;
|
||||
|
@ -204,7 +207,7 @@ describe("PollCreateDialog", () => {
|
|||
});
|
||||
|
||||
it("displays a spinner after submitting", () => {
|
||||
TestUtils.stubClient();
|
||||
stubClient();
|
||||
MatrixClientPeg.get().sendEvent = jest.fn(() => Promise.resolve());
|
||||
|
||||
const dialog = mount(
|
||||
|
@ -220,7 +223,7 @@ describe("PollCreateDialog", () => {
|
|||
});
|
||||
|
||||
it("sends a poll create event when submitted", () => {
|
||||
TestUtils.stubClient();
|
||||
stubClient();
|
||||
let sentEventContent: IContent = null;
|
||||
MatrixClientPeg.get().sendEvent = jest.fn(
|
||||
(
|
||||
|
@ -272,7 +275,7 @@ describe("PollCreateDialog", () => {
|
|||
});
|
||||
|
||||
it("sends a poll edit event when editing", () => {
|
||||
TestUtils.stubClient();
|
||||
stubClient();
|
||||
let sentEventContent: IContent = null;
|
||||
MatrixClientPeg.get().sendEvent = jest.fn(
|
||||
(
|
||||
|
|
|
@ -24,7 +24,7 @@ import '../../../skinned-sdk';
|
|||
import SpacePanel from '../../../../src/components/views/spaces/SpacePanel';
|
||||
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
|
||||
import { SpaceKey } from '../../../../src/stores/spaces';
|
||||
import { findByTestId } from '../../../utils/test-utils';
|
||||
import { findByTestId } from '../../../test-utils';
|
||||
import { shouldShowComponent } from '../../../../src/customisations/helpers/UIComponents';
|
||||
import { UIComponent } from '../../../../src/settings/UIFeature';
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { GuestAccess, HistoryVisibility, JoinRule } from 'matrix-js-sdk/src/@typ
|
|||
|
||||
import _SpaceSettingsVisibilityTab from "../../../../src/components/views/spaces/SpaceSettingsVisibilityTab";
|
||||
import { createTestClient, mkEvent, wrapInMatrixClientContext } from '../../../test-utils';
|
||||
import { mkSpace, mockStateEventImplementation } from '../../../utils/test-utils';
|
||||
import { mkSpace, mockStateEventImplementation } from '../../../test-utils';
|
||||
import { MatrixClientPeg } from '../../../../src/MatrixClientPeg';
|
||||
|
||||
const SpaceSettingsVisibilityTab = wrapInMatrixClientContext(_SpaceSettingsVisibilityTab);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue