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

Commit 697b5d2

Browse files
author
Kerry
authored
fix leaking registration test (#7304)
Signed-off-by: Kerry Archibald <[email protected]>
1 parent f9e3328 commit 697b5d2

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/components/structures/auth/Registration-test.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17+
import sdk from '../../../skinned-sdk';
18+
1719
import React from 'react';
1820
import ReactDOM from 'react-dom';
1921
import ReactTestUtils from 'react-dom/test-utils';
20-
import sdk from '../../../skinned-sdk';
22+
import { createClient } from 'matrix-js-sdk/src/matrix';
23+
2124
import SdkConfig from '../../../../src/SdkConfig';
22-
import { mkServerConfig } from "../../../test-utils";
25+
import { createTestClient, mkServerConfig } from "../../../test-utils";
26+
27+
jest.mock('matrix-js-sdk/src/matrix');
28+
jest.useFakeTimers();
2329

2430
const Registration = sdk.getComponent(
2531
'structures.auth.Registration',
@@ -31,6 +37,7 @@ describe('Registration', function() {
3137
beforeEach(function() {
3238
parentDiv = document.createElement('div');
3339
document.body.appendChild(parentDiv);
40+
createClient.mockImplementation(() => createTestClient());
3441
});
3542

3643
afterEach(function() {
@@ -48,13 +55,13 @@ describe('Registration', function() {
4855
/>, parentDiv);
4956
}
5057

51-
it('should show server picker', function() {
58+
it('should show server picker', async function() {
5259
const root = render();
5360
const selector = ReactTestUtils.findRenderedDOMComponentWithClass(root, "mx_ServerPicker");
5461
expect(selector).toBeTruthy();
5562
});
5663

57-
it('should show form when custom URLs disabled', function() {
64+
it('should show form when custom URLs disabled', async function() {
5865
jest.spyOn(SdkConfig, "get").mockReturnValue({
5966
disable_custom_urls: true,
6067
});
@@ -77,7 +84,7 @@ describe('Registration', function() {
7784
expect(form).toBeTruthy();
7885
});
7986

80-
it("should show SSO options if those are available", () => {
87+
it("should show SSO options if those are available", async () => {
8188
jest.spyOn(SdkConfig, "get").mockReturnValue({
8289
disable_custom_urls: true,
8390
});

0 commit comments

Comments
 (0)