Second batch: Replace MatrixClient.isRoomEncrypted by MatrixClient.CryptoApi.isEncryptionEnabledInRoom (#28466)
* Add `asyncFilter` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `MemberListStore.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `EventIndex.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `SendMessageComposer.tsx` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `ScalarMessaging.ts` * Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `RolesRoomSettingsTab.tsx` * Add reject doc to `asyncFilter` * Reverse `MemberListStore.loadMembers` condition * Remove async for `ScalarMessaging.ts` * Display permission section only after `isEncrypted` is computed * Display composer only after `isEncrypted` is computed * Revert "Display composer only after `isEncrypted` is computed" This reverts commit4d4e037391. * Revert "Replace `MatrixClient.isRoomEncrypted` by `MatrixClient.CryptoApi.isEncryptionEnabledInRoom` in `SendMessageComposer.tsx`" This reverts commit6bf06da02c.
This commit is contained in:
@@ -24,6 +24,7 @@ import {
|
||||
asyncEvery,
|
||||
asyncSome,
|
||||
asyncSomeParallel,
|
||||
asyncFilter,
|
||||
} from "../../../src/utils/arrays";
|
||||
|
||||
type TestParams = { input: number[]; output: number[] };
|
||||
@@ -480,4 +481,15 @@ describe("arrays", () => {
|
||||
expect(await asyncSomeParallel([1, 2, 3], predicate)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("asyncFilter", () => {
|
||||
it("when called with an empty array, it should return an empty array", async () => {
|
||||
expect(await asyncFilter([], jest.fn().mockResolvedValue(true))).toEqual([]);
|
||||
});
|
||||
|
||||
it("should filter the content", async () => {
|
||||
const predicate = jest.fn().mockImplementation((value) => Promise.resolve(value === 2));
|
||||
expect(await asyncFilter([1, 2, 3], predicate)).toEqual([2]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user