Test that forward buttons are disabled for rooms without permission

Signed-off-by: Robin Townsend <robin@robin.town>
This commit is contained in:
Robin Townsend 2021-05-10 01:07:42 -04:00
parent 09ba74a851
commit eb779cd3d8

View file

@ -147,4 +147,17 @@ describe("ForwardDialog", () => {
const wrapper = await mountForwardDialog(replyMessage);
expect(wrapper.find("ReplyThread")).toBeTruthy();
});
it("disables buttons for rooms without send permissions", async () => {
const readOnlyRoom = TestUtils.mkStubRoom("a", "a");
readOnlyRoom.maySendMessage = jest.fn().mockReturnValue(false);
const rooms = [readOnlyRoom, TestUtils.mkStubRoom("b", "b")];
const wrapper = await mountForwardDialog(undefined, rooms);
const firstButton = wrapper.find("Entry AccessibleButton").first();
expect(firstButton.prop("disabled")).toBe(true);
const secondButton = wrapper.find("Entry AccessibleButton").last();
expect(secondButton.prop("disabled")).toBe(false);
});
});