mirror of https://github.com/vector-im/riot-web
Find components by name rather than class in ForwardDialog test
It makes things shorter and more readable! Signed-off-by: Robin Townsend <robin@robin.town>pull/21833/head
parent
eb07f1fb86
commit
35cf0e1c7e
|
@ -80,15 +80,13 @@ describe("ForwardDialog", () => {
|
||||||
it("filters the rooms", async () => {
|
it("filters the rooms", async () => {
|
||||||
const wrapper = await mountForwardDialog();
|
const wrapper = await mountForwardDialog();
|
||||||
|
|
||||||
const roomsBefore = wrapper.find(".mx_ForwardList_entry");
|
expect(wrapper.find("Entry")).toHaveLength(3);
|
||||||
expect(roomsBefore).toHaveLength(3);
|
|
||||||
|
|
||||||
const searchInput = wrapper.find(".mx_SearchBox input");
|
const searchInput = wrapper.find("SearchBox input");
|
||||||
searchInput.instance().value = "a";
|
searchInput.instance().value = "a";
|
||||||
searchInput.simulate("change");
|
searchInput.simulate("change");
|
||||||
|
|
||||||
const roomsAfter = wrapper.find(".mx_ForwardList_entry");
|
expect(wrapper.find("Entry")).toHaveLength(2);
|
||||||
expect(roomsAfter).toHaveLength(2);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("tracks message sending progress across multiple rooms", async () => {
|
it("tracks message sending progress across multiple rooms", async () => {
|
||||||
|
@ -102,35 +100,31 @@ describe("ForwardDialog", () => {
|
||||||
cancelSend = reject;
|
cancelSend = reject;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const firstRoom = wrapper.find(".mx_ForwardList_entry").first();
|
const firstButton = wrapper.find("Entry AccessibleButton").first();
|
||||||
expect(firstRoom.find(".mx_AccessibleButton").text()).toBe("Send");
|
expect(firstButton.text()).toBe("Send");
|
||||||
|
|
||||||
act(() => {
|
act(() => { firstButton.simulate("click"); });
|
||||||
firstRoom.find(".mx_AccessibleButton").simulate("click");
|
expect(firstButton.text()).toBe("Sending…");
|
||||||
});
|
|
||||||
expect(firstRoom.find(".mx_AccessibleButton").text()).toBe("Sending…");
|
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
cancelSend();
|
cancelSend();
|
||||||
// Wait one tick for the button to realize the send failed
|
// Wait one tick for the button to realize the send failed
|
||||||
await new Promise(resolve => setImmediate(resolve));
|
await new Promise(resolve => setImmediate(resolve));
|
||||||
});
|
});
|
||||||
expect(firstRoom.find(".mx_AccessibleButton").text()).toBe("Failed to send");
|
expect(firstButton.text()).toBe("Failed to send");
|
||||||
|
|
||||||
const secondRoom = wrapper.find(".mx_ForwardList_entry").at(1);
|
const secondButton = wrapper.find("Entry AccessibleButton").at(1);
|
||||||
expect(secondRoom.find(".mx_AccessibleButton").text()).toBe("Send");
|
expect(secondButton.text()).toBe("Send");
|
||||||
|
|
||||||
act(() => {
|
act(() => { secondButton.simulate("click"); });
|
||||||
secondRoom.find(".mx_AccessibleButton").simulate("click");
|
expect(secondButton.text()).toBe("Sending…");
|
||||||
});
|
|
||||||
expect(secondRoom.find(".mx_AccessibleButton").text()).toBe("Sending…");
|
|
||||||
|
|
||||||
await act(async () => {
|
await act(async () => {
|
||||||
finishSend();
|
finishSend();
|
||||||
// Wait one tick for the button to realize the send succeeded
|
// Wait one tick for the button to realize the send succeeded
|
||||||
await new Promise(resolve => setImmediate(resolve));
|
await new Promise(resolve => setImmediate(resolve));
|
||||||
});
|
});
|
||||||
expect(secondRoom.find(".mx_AccessibleButton").text()).toBe("Sent");
|
expect(secondButton.text()).toBe("Sent");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("can render replies", async () => {
|
it("can render replies", async () => {
|
||||||
|
|
Loading…
Reference in New Issue