fix leaking registration test (#7304)
Signed-off-by: Kerry Archibald <kerrya@element.io>pull/21833/head
parent
f9e3328fb3
commit
697b5d28b3
|
@ -14,12 +14,18 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import sdk from '../../../skinned-sdk';
|
||||||
|
|
||||||
import React from 'react';
|
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 sdk from '../../../skinned-sdk';
|
import { createClient } from 'matrix-js-sdk/src/matrix';
|
||||||
|
|
||||||
import SdkConfig from '../../../../src/SdkConfig';
|
import SdkConfig from '../../../../src/SdkConfig';
|
||||||
import { mkServerConfig } from "../../../test-utils";
|
import { createTestClient, mkServerConfig } from "../../../test-utils";
|
||||||
|
|
||||||
|
jest.mock('matrix-js-sdk/src/matrix');
|
||||||
|
jest.useFakeTimers();
|
||||||
|
|
||||||
const Registration = sdk.getComponent(
|
const Registration = sdk.getComponent(
|
||||||
'structures.auth.Registration',
|
'structures.auth.Registration',
|
||||||
|
@ -31,6 +37,7 @@ describe('Registration', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
parentDiv = document.createElement('div');
|
parentDiv = document.createElement('div');
|
||||||
document.body.appendChild(parentDiv);
|
document.body.appendChild(parentDiv);
|
||||||
|
createClient.mockImplementation(() => createTestClient());
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function() {
|
afterEach(function() {
|
||||||
|
@ -48,13 +55,13 @@ describe('Registration', function() {
|
||||||
/>, parentDiv);
|
/>, parentDiv);
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should show server picker', function() {
|
it('should show server picker', async function() {
|
||||||
const root = render();
|
const root = render();
|
||||||
const selector = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_ServerPicker");
|
const selector = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_ServerPicker");
|
||||||
expect(selector).toBeTruthy();
|
expect(selector).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show form when custom URLs disabled', function() {
|
it('should show form when custom URLs disabled', async function() {
|
||||||
jest.spyOn(SdkConfig, "get").mockReturnValue({
|
jest.spyOn(SdkConfig, "get").mockReturnValue({
|
||||||
disable_custom_urls: true,
|
disable_custom_urls: true,
|
||||||
});
|
});
|
||||||
|
@ -77,7 +84,7 @@ describe('Registration', function() {
|
||||||
expect(form).toBeTruthy();
|
expect(form).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should show SSO options if those are available", () => {
|
it("should show SSO options if those are available", async () => {
|
||||||
jest.spyOn(SdkConfig, "get").mockReturnValue({
|
jest.spyOn(SdkConfig, "get").mockReturnValue({
|
||||||
disable_custom_urls: true,
|
disable_custom_urls: true,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue