@@ -28,6 +28,8 @@ import { HierarchyLevel, showRoom, toLocalRoom } from "../../../src/components/s
28
28
import { Action } from "../../../src/dispatcher/actions" ;
29
29
import MatrixClientContext from "../../../src/contexts/MatrixClientContext" ;
30
30
import DMRoomMap from "../../../src/utils/DMRoomMap" ;
31
+ import { mocked } from "jest-mock" ;
32
+ import SettingsStore from "../../../src/settings/SettingsStore" ;
31
33
32
34
// Fake random strings to give a predictable snapshot for checkbox IDs
33
35
jest . mock ( "matrix-js-sdk/src/randomstring" , ( ) => {
@@ -128,6 +130,34 @@ describe("SpaceHierarchy", () => {
128
130
const localRoomV3 = toLocalRoom ( client , { room_id : roomV3 . roomId } as IHierarchyRoom , hierarchy ) ;
129
131
expect ( localRoomV3 . room_id ) . toEqual ( roomV3 . roomId ) ;
130
132
} ) ;
133
+
134
+ describe ( "If the feature_dynamic_room_predecessors is not enabled" , ( ) => {
135
+ beforeEach ( ( ) => {
136
+ jest . spyOn ( SettingsStore , "getValue" ) . mockReturnValue ( false ) ;
137
+ } ) ;
138
+ it ( "Passes through the dynamic predecessor setting" , async ( ) => {
139
+ mocked ( client . getRoomUpgradeHistory ) . mockClear ( ) ;
140
+ const hierarchy = { roomMap : new Map ( [ ] ) } as RoomHierarchy ;
141
+ toLocalRoom ( client , { room_id : roomV1 . roomId } as IHierarchyRoom , hierarchy ) ;
142
+ expect ( client . getRoomUpgradeHistory ) . toHaveBeenCalledWith ( roomV1 . roomId , true , false ) ;
143
+ } ) ;
144
+ } ) ;
145
+
146
+ describe ( "If the feature_dynamic_room_predecessors is enabled" , ( ) => {
147
+ beforeEach ( ( ) => {
148
+ // Turn on feature_dynamic_room_predecessors setting
149
+ jest . spyOn ( SettingsStore , "getValue" ) . mockImplementation (
150
+ ( settingName ) => settingName === "feature_dynamic_room_predecessors" ,
151
+ ) ;
152
+ } ) ;
153
+
154
+ it ( "Passes through the dynamic predecessor setting" , async ( ) => {
155
+ mocked ( client . getRoomUpgradeHistory ) . mockClear ( ) ;
156
+ const hierarchy = { roomMap : new Map ( [ ] ) } as RoomHierarchy ;
157
+ toLocalRoom ( client , { room_id : roomV1 . roomId } as IHierarchyRoom , hierarchy ) ;
158
+ expect ( client . getRoomUpgradeHistory ) . toHaveBeenCalledWith ( roomV1 . roomId , true , true ) ;
159
+ } ) ;
160
+ } ) ;
131
161
} ) ;
132
162
133
163
describe ( "<HierarchyLevel />" , ( ) => {
0 commit comments