fix ts issues in Registration-test (#8579)

Signed-off-by: Kerry Archibald <kerrya@element.io>
pull/28217/head
Kerry 2022-05-16 10:23:51 +02:00 committed by GitHub
parent 8ae9f7d79a
commit 42f12485bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 8 deletions

View File

@ -1,5 +1,6 @@
/* /*
Copyright 2019 New Vector Ltd Copyright 2019 New Vector Ltd
Copyright 2022 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -18,6 +19,7 @@ import React from 'react';
import ReactDOM from 'react-dom'; import ReactDOM from 'react-dom';
import ReactTestUtils from 'react-dom/test-utils'; import ReactTestUtils from 'react-dom/test-utils';
import { createClient } from 'matrix-js-sdk/src/matrix'; import { createClient } from 'matrix-js-sdk/src/matrix';
import { mocked } from 'jest-mock';
import SdkConfig, { DEFAULTS } from '../../../../src/SdkConfig'; import SdkConfig, { DEFAULTS } from '../../../../src/SdkConfig';
import { createTestClient, mkServerConfig } from "../../../test-utils"; import { createTestClient, mkServerConfig } from "../../../test-utils";
@ -37,7 +39,7 @@ describe('Registration', function() {
}); });
parentDiv = document.createElement('div'); parentDiv = document.createElement('div');
document.body.appendChild(parentDiv); document.body.appendChild(parentDiv);
createClient.mockImplementation(() => createTestClient()); mocked(createClient).mockImplementation(() => createTestClient());
}); });
afterEach(function() { afterEach(function() {
@ -46,14 +48,18 @@ describe('Registration', function() {
SdkConfig.unset(); // we touch the config, so clean up SdkConfig.unset(); // we touch the config, so clean up
}); });
const defaultProps = {
defaultDeviceDisplayName: 'test-device-display-name',
serverConfig: mkServerConfig("https://matrix.org", "https://vector.im"),
makeRegistrationUrl: jest.fn(),
onLoggedIn: jest.fn(),
onLoginClick: jest.fn(),
onServerConfigChange: jest.fn(),
};
function render() { function render() {
return ReactDOM.render(<Registration return ReactDOM.render<typeof Registration>(<Registration
serverConfig={mkServerConfig("https://matrix.org", "https://vector.im")} {...defaultProps}
makeRegistrationUrl={() => {}} />, parentDiv) as React.Component<typeof Registration>;
onLoggedIn={() => {}}
onLoginClick={() => {}}
onServerConfigChange={() => {}}
/>, parentDiv);
} }
it('should show server picker', async function() { it('should show server picker', async function() {