Fix tests to use new serverConfig prop

This commit is contained in:
Travis Ralston 2019-05-02 23:46:43 -06:00
parent a4b6464902
commit ae63df95ea
3 changed files with 16 additions and 4 deletions

View file

@ -22,6 +22,7 @@ import ReactTestUtils from 'react-dom/test-utils';
import sdk from 'matrix-react-sdk';
import SdkConfig from '../../../../src/SdkConfig';
import * as TestUtils from '../../../test-utils';
import {mkServerConfig} from "../../../test-utils";
const Login = sdk.getComponent(
'structures.auth.Login',
@ -44,8 +45,7 @@ describe('Login', function() {
function render() {
return ReactDOM.render(<Login
defaultHsUrl="https://matrix.org"
defaultIsUrl="https://vector.im"
serverConfig={mkServerConfig("https://matrix.org", "https://vector.im")}
onLoggedIn={() => {}}
onRegisterClick={() => {}}
onServerConfigChange={() => {}}

View file

@ -22,6 +22,7 @@ import ReactTestUtils from 'react-dom/test-utils';
import sdk from 'matrix-react-sdk';
import SdkConfig from '../../../../src/SdkConfig';
import * as TestUtils from '../../../test-utils';
import {mkServerConfig} from "../../../test-utils";
const Registration = sdk.getComponent(
'structures.auth.Registration',
@ -44,8 +45,7 @@ describe('Registration', function() {
function render() {
return ReactDOM.render(<Registration
defaultHsUrl="https://matrix.org"
defaultIsUrl="https://vector.im"
serverConfig={mkServerConfig("https://matrix.org", "https://vector.im")}
makeRegistrationUrl={() => {}}
onLoggedIn={() => {}}
onLoginClick={() => {}}

View file

@ -7,6 +7,8 @@ import PropTypes from 'prop-types';
import peg from '../src/MatrixClientPeg';
import dis from '../src/dispatcher';
import jssdk from 'matrix-js-sdk';
import {makeType} from "../src/utils/TypeUtils";
import {ValidatedServerConfig} from "../src/utils/AutoDiscoveryUtils";
const MatrixEvent = jssdk.MatrixEvent;
/**
@ -260,6 +262,16 @@ export function mkStubRoom(roomId = null) {
};
}
export function mkServerConfig(hsUrl, isUrl) {
return makeType(ValidatedServerConfig, {
hsUrl,
hsName: "TEST_ENVIRONMENT",
hsNameIsDifferent: false, // yes, we lie
isUrl,
identityEnabled: true,
});
}
export function getDispatchForStore(store) {
// Mock the dispatcher by gut-wrenching. Stores can only __emitChange whilst a
// dispatcher `_isDispatching` is true.