@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
66Please see LICENSE files in the repository root for full details.
77*/
88
9- import { type MatrixClient } from "matrix-js-sdk/src/matrix" ;
9+ import { Direction , EventType , type MatrixClient , MatrixEvent } from "matrix-js-sdk/src/matrix" ;
1010
1111import { LocalRoom , LocalRoomState , LOCAL_ROOM_ID_PREFIX } from "../../../src/models/LocalRoom" ;
1212import { createTestClient } from "../../test-utils" ;
@@ -79,4 +79,26 @@ describe("LocalRoom", () => {
7979 } ) ;
8080 } ) ;
8181 } ) ;
82+
83+ it ( "should return false for isEncryptionEnabled with no state" , ( ) => {
84+ expect ( room . isEncryptionEnabled ( ) ) . toBe ( false ) ;
85+ } ) ;
86+
87+ it ( "should return true for isEncryptionEnabled with an encryption state event" , ( ) => {
88+ const encryptionEvent = new MatrixEvent ( {
89+ type : EventType . RoomEncryption ,
90+ state_key : "" ,
91+ content : {
92+ algorithm : "m.megolm.v1.aes-sha2" ,
93+ } ,
94+ sender : "@test:localhost" ,
95+ room_id : room . roomId ,
96+ event_id : "$test:localhost" ,
97+ } ) ;
98+
99+ const roomState = room . getLiveTimeline ( ) . getState ( Direction . Forward ) ;
100+ roomState ?. setStateEvents ( [ encryptionEvent ] ) ;
101+
102+ expect ( room . isEncryptionEnabled ( ) ) . toBe ( true ) ;
103+ } ) ;
82104} ) ;
0 commit comments