Write tests

This commit is contained in:
R Midhun Suresh 2025-10-30 18:33:07 +05:30
parent f4e8e79af8
commit 6dc1431270
No known key found for this signature in database

View File

@ -37,5 +37,25 @@ describe("NavigationApi", () => {
}),
);
});
it("should dispatch correct action on openRoom", () => {
const spy = jest.spyOn(defaultDispatcher, "dispatch");
// Non alias
api.openRoom("!foo:m.org");
expect(spy).toHaveBeenCalledWith(
expect.objectContaining({
action: "view_room",
room_id: "!foo:m.org",
}),
);
// Alias
api.openRoom("#bar:m.org");
expect(spy).toHaveBeenCalledWith(
expect.objectContaining({
action: "view_room",
room_alias: "#bar:m.org",
}),
);
});
});
});