Skip to content

Commit 77a7960

Browse files
committed
Update tests accordingly
1 parent b810609 commit 77a7960

File tree

4 files changed

+179
-12
lines changed

4 files changed

+179
-12
lines changed

test/unit-tests/components/viewmodels/roomlist/RoomListHeaderViewModel-test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,11 @@ describe("useRoomListHeaderViewModel", () => {
221221

222222
// Change the sort option
223223
act(() => {
224-
vm.current.sort(SortOption.AToZ);
224+
vm.current.sort(SortOption.AToZ, false);
225225
});
226226

227227
// Resort method in RLS must have been called
228-
expect(resort).toHaveBeenCalledWith(SortingAlgorithm.Alphabetic);
228+
expect(resort).toHaveBeenCalledWith(SortingAlgorithm.Alphabetic, [null]);
229229
});
230230

231231
it("should set activeSortOption based on value from settings", () => {

test/unit-tests/components/views/rooms/RoomListPanel/RoomListOptionsMenu-test.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe("<RoomListOptionsMenu />", () => {
6464

6565
const vm = {
6666
sort: jest.fn(),
67+
grouped: false,
6768
} as unknown as RoomListHeaderViewState;
6869

6970
render(<RoomListOptionsMenu vm={vm} />);
@@ -72,7 +73,7 @@ describe("<RoomListOptionsMenu />", () => {
7273

7374
await user.click(screen.getByRole("menuitemradio", { name: "A-Z" }));
7475

75-
expect(vm.sort).toHaveBeenCalledWith("Alphabetic");
76+
expect(vm.sort).toHaveBeenCalledWith("Alphabetic", false);
7677
});
7778

7879
it("should sort by activity", async () => {
@@ -81,6 +82,7 @@ describe("<RoomListOptionsMenu />", () => {
8182
const vm = {
8283
sort: jest.fn(),
8384
activeSortOption: "Alphabetic",
85+
grouped: false,
8486
} as unknown as RoomListHeaderViewState;
8587

8688
render(<RoomListOptionsMenu vm={vm} />);
@@ -89,6 +91,6 @@ describe("<RoomListOptionsMenu />", () => {
8991

9092
await user.click(screen.getByRole("menuitemradio", { name: "Activity" }));
9193

92-
expect(vm.sort).toHaveBeenCalledWith("Recency");
94+
expect(vm.sort).toHaveBeenCalledWith("Recency", false);
9395
});
9496
});

test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,31 @@ describe("RoomListStoreV3", () => {
7878
const { store, rooms, client } = await getRoomListStore();
7979

8080
// List is sorted by recency, sort by alphabetical now
81-
store.resort(SortingAlgorithm.Alphabetic);
81+
store.resort(SortingAlgorithm.Alphabetic, [null]);
8282
let sortedRooms = new AlphabeticSorter().sort(rooms);
8383
expect(store.getSortedRooms()).toEqual(sortedRooms);
84-
expect(store.activeSortAlgorithm).toEqual(SortingAlgorithm.Alphabetic);
84+
expect(store.activeSortAlgorithm).toEqual("grouping|Alphabetic|");
8585

8686
// Go back to recency sorting
87-
store.resort(SortingAlgorithm.Recency);
87+
store.resort(SortingAlgorithm.Recency, [null]);
8888
sortedRooms = new RecencySorter(client.getSafeUserId()).sort(rooms);
8989
expect(store.getSortedRooms()).toEqual(sortedRooms);
90-
expect(store.activeSortAlgorithm).toEqual(SortingAlgorithm.Recency);
90+
expect(store.activeSortAlgorithm).toEqual("grouping|Recency|");
9191
});
9292

9393
it("Uses preferred sorter on startup", async () => {
94-
jest.spyOn(SettingsStore, "getValue").mockImplementation(() => {
95-
return SortingAlgorithm.Alphabetic;
94+
jest.spyOn(SettingsStore, "getValue").mockImplementation(key => {
95+
switch (key) {
96+
case "RoomList.preferredSorting":
97+
return SortingAlgorithm.Alphabetic;
98+
case "RoomList.sections":
99+
return [null];
100+
default:
101+
return null;
102+
}
96103
});
97104
const { store } = await getRoomListStore();
98-
expect(store.activeSortAlgorithm).toEqual(SortingAlgorithm.Alphabetic);
105+
expect(store.activeSortAlgorithm).toEqual("grouping|Alphabetic|");
99106
});
100107

101108
describe("Updates", () => {

test/unit-tests/utils/exportUtils/__snapshots__/HTMLExport-test.ts.snap

Lines changed: 159 additions & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)