Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

fix leaking unit test for Registration #7304

Merged
merged 1 commit into from
Dec 8, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions test/components/structures/auth/Registration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

import sdk from '../../../skinned-sdk';

import React from 'react';
import ReactDOM from 'react-dom';
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 { mkServerConfig } from "../../../test-utils";
import { createTestClient, mkServerConfig } from "../../../test-utils";

jest.mock('matrix-js-sdk/src/matrix');
jest.useFakeTimers();

const Registration = sdk.getComponent(
'structures.auth.Registration',
Expand All @@ -31,6 +37,7 @@ describe('Registration', function() {
beforeEach(function() {
parentDiv = document.createElement('div');
document.body.appendChild(parentDiv);
createClient.mockImplementation(() => createTestClient());
});

afterEach(function() {
Expand All @@ -48,13 +55,13 @@ describe('Registration', function() {
/>, parentDiv);
}

it('should show server picker', function() {
it('should show server picker', async function() {
const root = render();
const selector = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_ServerPicker");
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({
disable_custom_urls: true,
});
Expand All @@ -77,7 +84,7 @@ describe('Registration', function() {
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({
disable_custom_urls: true,
});
Expand Down