You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Step 3.1: Stop using getComponent
in tests
This commit is contained in:
@@ -24,7 +24,6 @@ import { mount } from "enzyme";
|
||||
import * as TestUtils from "react-dom/test-utils";
|
||||
|
||||
import { MatrixClientPeg } from '../../../src/MatrixClientPeg';
|
||||
import sdk from '../../skinned-sdk';
|
||||
import MessagePanel, { shouldFormContinuation } from "../../../src/components/structures/MessagePanel";
|
||||
import SettingsStore from "../../../src/settings/SettingsStore";
|
||||
import MatrixClientContext from "../../../src/contexts/MatrixClientContext";
|
||||
@@ -32,6 +31,9 @@ import RoomContext from "../../../src/contexts/RoomContext";
|
||||
import DMRoomMap from "../../../src/utils/DMRoomMap";
|
||||
import { UnwrappedEventTile } from "../../../src/components/views/rooms/EventTile";
|
||||
import * as TestUtilsMatrix from "../../test-utils";
|
||||
import EventListSummary from "../../../src/components/views/elements/EventListSummary";
|
||||
import GenericEventListSummary from "../../../src/components/views/elements/GenericEventListSummary";
|
||||
import DateSeparator from "../../../src/components/views/messages/DateSeparator";
|
||||
|
||||
let client;
|
||||
const room = new Matrix.Room("!roomId:server_name");
|
||||
@@ -298,7 +300,7 @@ describe('MessagePanel', function() {
|
||||
expect(tiles.length).toEqual(2);
|
||||
|
||||
const summaryTiles = TestUtils.scryRenderedComponentsWithType(
|
||||
res, sdk.getComponent('elements.EventListSummary'),
|
||||
res, EventListSummary,
|
||||
);
|
||||
expect(summaryTiles.length).toEqual(1);
|
||||
});
|
||||
@@ -443,7 +445,7 @@ describe('MessagePanel', function() {
|
||||
expect(tiles.at(0).props().mxEvent.getType()).toEqual("m.room.create");
|
||||
expect(tiles.at(1).props().mxEvent.getType()).toEqual("m.room.encryption");
|
||||
|
||||
const summaryTiles = res.find(sdk.getComponent('views.elements.GenericEventListSummary'));
|
||||
const summaryTiles = res.find(GenericEventListSummary);
|
||||
const summaryTile = summaryTiles.at(0);
|
||||
|
||||
const summaryEventTiles = summaryTile.find(UnwrappedEventTile);
|
||||
@@ -483,7 +485,7 @@ describe('MessagePanel', function() {
|
||||
events={events}
|
||||
/>,
|
||||
);
|
||||
const Dates = res.find(sdk.getComponent('messages.DateSeparator'));
|
||||
const Dates = res.find(DateSeparator);
|
||||
|
||||
expect(Dates.length).toEqual(1);
|
||||
});
|
||||
|
@@ -20,9 +20,10 @@ import ReactTestUtils from 'react-dom/test-utils';
|
||||
import { mocked } from 'jest-mock';
|
||||
import { createClient, MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import sdk from '../../../skinned-sdk';
|
||||
import SdkConfig from '../../../../src/SdkConfig';
|
||||
import { mkServerConfig } from "../../../test-utils";
|
||||
import Login from "../../../../src/components/structures/auth/Login";
|
||||
import PasswordLogin from "../../../../src/components/views/auth/PasswordLogin";
|
||||
|
||||
jest.mock("matrix-js-sdk/src/matrix");
|
||||
|
||||
@@ -30,10 +31,6 @@ const flushPromises = async () => await new Promise(process.nextTick);
|
||||
|
||||
jest.useRealTimers();
|
||||
|
||||
const Login = sdk.getComponent(
|
||||
'structures.auth.Login',
|
||||
);
|
||||
|
||||
describe('Login', function() {
|
||||
let parentDiv;
|
||||
const mockClient = mocked({
|
||||
@@ -80,7 +77,7 @@ describe('Login', function() {
|
||||
|
||||
const form = ReactTestUtils.findRenderedComponentWithType(
|
||||
root,
|
||||
sdk.getComponent('auth.PasswordLogin'),
|
||||
PasswordLogin,
|
||||
);
|
||||
expect(form).toBeTruthy();
|
||||
|
||||
@@ -94,7 +91,7 @@ describe('Login', function() {
|
||||
|
||||
const form = ReactTestUtils.findRenderedComponentWithType(
|
||||
root,
|
||||
sdk.getComponent('auth.PasswordLogin'),
|
||||
PasswordLogin,
|
||||
);
|
||||
expect(form).toBeTruthy();
|
||||
|
||||
@@ -118,7 +115,7 @@ describe('Login', function() {
|
||||
const root = render();
|
||||
await flushPromises();
|
||||
|
||||
const form = ReactTestUtils.findRenderedComponentWithType(root, sdk.getComponent('auth.PasswordLogin'));
|
||||
const form = ReactTestUtils.findRenderedComponentWithType(root, PasswordLogin);
|
||||
expect(form).toBeTruthy();
|
||||
|
||||
const ssoButton = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_SSOButton");
|
||||
|
@@ -19,17 +19,14 @@ import ReactDOM from 'react-dom';
|
||||
import ReactTestUtils from 'react-dom/test-utils';
|
||||
import { createClient } from 'matrix-js-sdk/src/matrix';
|
||||
|
||||
import sdk from '../../../skinned-sdk';
|
||||
import SdkConfig, { DEFAULTS } from '../../../../src/SdkConfig';
|
||||
import { createTestClient, mkServerConfig } from "../../../test-utils";
|
||||
import Registration from "../../../../src/components/structures/auth/Registration";
|
||||
import RegistrationForm from "../../../../src/components/views/auth/RegistrationForm";
|
||||
|
||||
jest.mock('matrix-js-sdk/src/matrix');
|
||||
jest.useFakeTimers();
|
||||
|
||||
const Registration = sdk.getComponent(
|
||||
'structures.auth.Registration',
|
||||
);
|
||||
|
||||
describe('Registration', function() {
|
||||
let parentDiv;
|
||||
|
||||
@@ -79,7 +76,7 @@ describe('Registration', function() {
|
||||
|
||||
const form = ReactTestUtils.findRenderedComponentWithType(
|
||||
root,
|
||||
sdk.getComponent('auth.RegistrationForm'),
|
||||
RegistrationForm,
|
||||
);
|
||||
expect(form).toBeTruthy();
|
||||
});
|
||||
|
Reference in New Issue
Block a user