From 970d1912e52c9357481538a4f1a9e1a906a15f57 Mon Sep 17 00:00:00 2001 From: Germain Date: Thu, 13 Oct 2022 18:22:25 +0100 Subject: [PATCH] Add mock for canSupport (#9414) * Add mock for canSupport * dead code --- test/test-utils/client.ts | 6 ++++++ test/test-utils/test-utils.ts | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/test/test-utils/client.ts b/test/test-utils/client.ts index d6ec3f2fd3..6478743458 100644 --- a/test/test-utils/client.ts +++ b/test/test-utils/client.ts @@ -16,6 +16,7 @@ limitations under the License. import EventEmitter from "events"; import { MethodKeysOf, mocked, MockedObject, PropertyKeysOf } from "jest-mock"; +import { Feature, ServerSupport } from "matrix-js-sdk/src/feature"; import { MatrixClient, User } from "matrix-js-sdk/src/matrix"; import { MatrixClientPeg } from "../../src/MatrixClientPeg"; @@ -50,6 +51,11 @@ export const getMockClientWithEventEmitter = ( const mock = mocked(new MockClientWithEventEmitter(mockProperties) as unknown as MatrixClient); jest.spyOn(MatrixClientPeg, 'get').mockReturnValue(mock); + + mock.canSupport = new Map(); + Object.keys(Feature).forEach(feature => { + mock.canSupport.set(feature as Feature, ServerSupport.Stable); + }); return mock; }; diff --git a/test/test-utils/test-utils.ts b/test/test-utils/test-utils.ts index 60091be2a7..d04324c8ca 100644 --- a/test/test-utils/test-utils.ts +++ b/test/test-utils/test-utils.ts @@ -35,6 +35,7 @@ import { import { normalize } from "matrix-js-sdk/src/utils"; import { ReEmitter } from "matrix-js-sdk/src/ReEmitter"; import { MediaHandler } from "matrix-js-sdk/src/webrtc/mediaHandler"; +import { Feature, ServerSupport } from "matrix-js-sdk/src/feature"; import { MatrixClientPeg as peg } from '../../src/MatrixClientPeg'; import { makeType } from "../../src/utils/TypeUtils"; @@ -187,6 +188,11 @@ export function createTestClient(): MatrixClient { client.reEmitter = new ReEmitter(client); + client.canSupport = new Map(); + Object.keys(Feature).forEach(feature => { + client.canSupport.set(feature as Feature, ServerSupport.Stable); + }); + Object.defineProperty(client, "pollingTurnServers", { configurable: true, get: () => true,