Add ESLint Jest (#10261)

This commit is contained in:
Michael Weimann 2023-03-01 16:23:35 +01:00 committed by GitHub
parent db7748b743
commit 5398db21ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 336 additions and 351 deletions

View file

@ -46,7 +46,6 @@ const roomId = "!roomId:server_name";
describe("MessagePanel", function () {
let clock: FakeTimers.InstalledClock;
const realSetTimeout = window.setTimeout;
const events = mkEvents();
const userId = "@me:here";
const client = getMockClientWithEventEmitter({
@ -404,7 +403,7 @@ describe("MessagePanel", function () {
expect(isReadMarkerVisible(rm)).toBeFalsy();
});
it("shows a ghost read-marker when the read-marker moves", function (done) {
it("shows a ghost read-marker when the read-marker moves", function () {
// fake the clock so that we can test the velocity animation.
clock = FakeTimers.install();
@ -446,19 +445,9 @@ describe("MessagePanel", function () {
// the second should be the real thing
expect(readMarkers[1].previousSibling).toEqual(tiles[6]);
// advance the clock, and then let the browser run an animation frame,
// to let the animation start
// advance the clock, and then let the browser run an animation frame to let the animation start
clock.tick(1500);
realSetTimeout(() => {
// then advance it again to let it complete
clock.tick(1000);
realSetTimeout(() => {
// the ghost should now have finished
expect(hr.style.opacity).toEqual("0");
done();
}, 100);
}, 100);
expect(hr.style.opacity).toEqual("0");
});
it("should collapse creation events", function () {

View file

@ -147,7 +147,7 @@ describe("ThreadView", () => {
);
});
it("sends a message with the correct fallback", async () => {
it("sends a thread message with the correct fallback", async () => {
const { container } = await getComponent();
const { rootEvent: rootEvent2 } = mkThread({

View file

@ -84,7 +84,7 @@ describe("InteractiveAuthComponent", function () {
await flushPromises();
expect(makeRequest).toHaveBeenCalledTimes(1);
expect(makeRequest).toBeCalledWith(
expect(makeRequest).toHaveBeenCalledWith(
expect.objectContaining({
session: "sess",
type: "m.login.registration_token",
@ -92,8 +92,8 @@ describe("InteractiveAuthComponent", function () {
}),
);
expect(onAuthFinished).toBeCalledTimes(1);
expect(onAuthFinished).toBeCalledWith(
expect(onAuthFinished).toHaveBeenCalledTimes(1);
expect(onAuthFinished).toHaveBeenCalledWith(
true,
{ a: 1 },
{ clientSecret: "t35tcl1Ent5ECr3T", emailSid: undefined },

View file

@ -79,7 +79,7 @@ describe("InteractiveAuthDialog", function () {
await flushPromises();
expect(makeRequest).toHaveBeenCalledTimes(1);
expect(makeRequest).toBeCalledWith(
expect(makeRequest).toHaveBeenCalledWith(
expect.objectContaining({
session: "sess",
type: "m.login.password",
@ -91,7 +91,7 @@ describe("InteractiveAuthDialog", function () {
}),
);
expect(onFinished).toBeCalledTimes(1);
expect(onFinished).toBeCalledWith(true, { a: 1 });
expect(onFinished).toHaveBeenCalledTimes(1);
expect(onFinished).toHaveBeenCalledWith(true, { a: 1 });
});
});

View file

@ -69,7 +69,7 @@ describe("<MessageEditHistory />", () => {
expect(container).toMatchSnapshot();
});
it("should support events with ", async () => {
it("should support events with", async () => {
mockEdits(
{ msg: "My Great Massage", ts: undefined },
{ msg: "My Great Massage?", ts: undefined },

View file

@ -112,7 +112,7 @@ exports[`<MessageEditHistory /> should match the snapshot 1`] = `
</div>
`;
exports[`<MessageEditHistory /> should support events with 1`] = `
exports[`<MessageEditHistory /> should support events with 1`] = `
<div>
<div
data-focus-guard="true"

View file

@ -431,30 +431,5 @@ describe("<PollHistoryDialog />", () => {
`https://matrix.to/#/!room:domain.org/${pollEnd3.getId()!}`,
);
});
it("navigates back to poll list from detail view on header click", async () => {
await setupRoomWithPollEvents([pollStart1, pollStart2, pollStart3], [], [pollEnd3], mockClient, room);
const { getByText, queryByText, getByTestId, container } = getComponent();
await flushPromises();
fireEvent.click(getByText("Question?"));
// detail view
expect(getByText("Question?")).toBeInTheDocument();
// header not shown
expect(queryByText("Polls history")).not.toBeInTheDocument();
expect(getByText("Active polls")).toMatchSnapshot();
fireEvent.click(getByText("Active polls"));
// main list header displayed again
expect(getByText("Polls history")).toBeInTheDocument();
// active filter still active
expect(getByTestId("filter-tab-PollHistoryDialog_filter-ACTIVE").firstElementChild).toBeChecked();
// list displayed
expect(container.getElementsByClassName("mx_PollHistoryList_list").length).toBeTruthy();
});
});
});

View file

@ -29,19 +29,6 @@ exports[`<PollHistoryDialog /> Poll detail navigates back to poll list from deta
</div>
`;
exports[`<PollHistoryDialog /> Poll detail navigates back to poll list from detail view on header click 2`] = `
<div
class="mx_AccessibleButton mx_PollDetailHeader mx_AccessibleButton_hasKind mx_AccessibleButton_kind_content_inline"
role="button"
tabindex="0"
>
<div
class="mx_PollDetailHeader_icon"
/>
Active polls
</div>
`;
exports[`<PollHistoryDialog /> renders a list of active polls when there are polls in the room 1`] = `
<div>
<div

View file

@ -156,7 +156,7 @@ describe("EventListSummary", function () {
expect(children[0]).toHaveTextContent("Expanded membership");
});
it("renders expanded events if there are less than props.threshold", function () {
it("renders expanded events if there are less than props.threshold for join and leave", function () {
const events = generateEvents([
{ userId: "@user_1:some.domain", prevMembership: "leave", membership: "join" },
{ userId: "@user_1:some.domain", prevMembership: "join", membership: "leave" },

View file

@ -252,15 +252,6 @@ describe("<MBeaconBody />", () => {
expect(modalSpy).toHaveBeenCalled();
});
it("does nothing on click when a beacon has no location", () => {
makeRoomWithStateEvents([aliceBeaconInfo], { roomId, mockClient });
const component = getComponent({ mxEvent: aliceBeaconInfo });
fireEvent.click(component.container.querySelector(".mx_MBeaconBody_map")!);
expect(modalSpy).not.toHaveBeenCalled();
});
it("updates latest location", () => {
const room = makeRoomWithStateEvents([aliceBeaconInfo], { roomId, mockClient });
getComponent({ mxEvent: aliceBeaconInfo });

View file

@ -958,7 +958,7 @@ function endedVotesCount(renderResult: RenderResult, value: string): string {
return votesCount(renderResult, value);
}
export function newPollStart(answers?: PollAnswer[], question?: string, disclosed = true): PollStartEventContent {
function newPollStart(answers?: PollAnswer[], question?: string, disclosed = true): PollStartEventContent {
if (!answers) {
answers = [
{ id: "pizza", [M_TEXT.name]: "Pizza" },
@ -1033,7 +1033,7 @@ function expectedResponseEventCall(answer: string) {
return [roomId, eventType, content];
}
export function newPollEndEvent(sender = "@me:example.com", ts = 0): MatrixEvent {
function newPollEndEvent(sender = "@me:example.com", ts = 0): MatrixEvent {
return makePollEndEvent("$mypoll", "#myroom:example.com", sender, ts);
}

View file

@ -195,7 +195,7 @@ describe("<MessageActionBar />", () => {
// because beforeRedaction event is fired... before redaction
// event is unchanged at point when this component updates
// TODO file bug
xit("updates component on before redaction event", () => {
it.skip("updates component on before redaction event", () => {
const event = new MatrixEvent({
type: EventType.RoomMessage,
sender: userId,

View file

@ -420,7 +420,7 @@ describe("<UserOptionsSection />", () => {
expect(screen.getByRole("button", { name: /share link to user/i })).toBeInTheDocument();
});
it("does not show ignore or direct message buttons when member userId matches client userId ", () => {
it("does not show ignore or direct message buttons when member userId matches client userId", () => {
mockClient.getUserId.mockReturnValueOnce(member.userId);
renderComponent();
@ -428,7 +428,7 @@ describe("<UserOptionsSection />", () => {
expect(screen.queryByRole("button", { name: /message/i })).not.toBeInTheDocument();
});
it("shows ignore, direct message and mention buttons when member userId does not match client userId ", () => {
it("shows ignore, direct message and mention buttons when member userId does not match client userId", () => {
// call to client.getUserId returns undefined, which will not match member.userId
renderComponent();

View file

@ -137,13 +137,11 @@ describe("MemberList", () => {
) as unknown as Component;
});
afterEach((done) => {
afterEach(() => {
if (parentDiv) {
ReactDOM.unmountComponentAtNode(parentDiv);
parentDiv.remove();
}
done();
});
function expectOrderedByPresenceAndPowerLevel(memberTiles: MemberTile[], isPresenceEnabled: boolean) {

View file

@ -177,12 +177,12 @@ describe("EditWysiwygComposer", () => {
screen.getByText("Cancel").click();
// Then
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.EditEvent,
event: null,
timelineRenderingType: defaultRoomContext.timelineRenderingType,
});
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.FocusSendMessageComposer,
context: defaultRoomContext.timelineRenderingType,
});
@ -215,10 +215,10 @@ describe("EditWysiwygComposer", () => {
"msgtype": "m.text",
};
await waitFor(() =>
expect(mockClient.sendMessage).toBeCalledWith(mockEvent.getRoomId(), null, expectedContent),
expect(mockClient.sendMessage).toHaveBeenCalledWith(mockEvent.getRoomId(), null, expectedContent),
);
expect(spyDispatcher).toBeCalledWith({ action: "message_sent" });
expect(spyDispatcher).toHaveBeenCalledWith({ action: "message_sent" });
});
});

View file

@ -84,7 +84,7 @@ describe("LinkModal", () => {
// Then
await waitFor(() => {
expect(selectionSpy).toHaveBeenCalledWith(defaultValue);
expect(onFinished).toBeCalledTimes(1);
expect(onFinished).toHaveBeenCalledTimes(1);
});
// Then
@ -127,7 +127,7 @@ describe("LinkModal", () => {
// Then
await waitFor(() => {
expect(selectionSpy).toHaveBeenCalledWith(defaultValue);
expect(onFinished).toBeCalledTimes(1);
expect(onFinished).toHaveBeenCalledTimes(1);
});
// Then
@ -142,7 +142,7 @@ describe("LinkModal", () => {
// Then
expect(formattingFunctions.removeLinks).toHaveBeenCalledTimes(1);
expect(onFinished).toBeCalledTimes(1);
expect(onFinished).toHaveBeenCalledTimes(1);
});
it("Should display the link in editing", async () => {

View file

@ -74,7 +74,7 @@ describe("PlainTextComposer", () => {
await userEvent.type(screen.getByRole("textbox"), content);
// Then
expect(onChange).toBeCalledWith(content);
expect(onChange).toHaveBeenCalledWith(content);
});
it("Should call onSend when Enter is pressed when ctrlEnterToSend is false", async () => {
@ -84,7 +84,7 @@ describe("PlainTextComposer", () => {
await userEvent.type(screen.getByRole("textbox"), "{enter}");
// Then it sends a message
expect(onSend).toBeCalledTimes(1);
expect(onSend).toHaveBeenCalledTimes(1);
});
it("Should not call onSend when Enter is pressed when ctrlEnterToSend is true", async () => {
@ -95,7 +95,7 @@ describe("PlainTextComposer", () => {
await userEvent.type(screen.getByRole("textbox"), "{enter}");
// Then it does not send a message
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
});
it("Should only call onSend when ctrl+enter is pressed when ctrlEnterToSend is true on windows", async () => {
@ -109,15 +109,15 @@ describe("PlainTextComposer", () => {
// Then it does NOT send a message on enter
await userEvent.type(textBox, "{enter}");
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
// Then it does NOT send a message on windows+enter
await userEvent.type(textBox, "{meta>}{enter}{meta/}");
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
// Then it does send a message on ctrl+enter
await userEvent.type(textBox, "{control>}{enter}{control/}");
expect(onSend).toBeCalledTimes(1);
expect(onSend).toHaveBeenCalledTimes(1);
});
it("Should only call onSend when cmd+enter is pressed when ctrlEnterToSend is true on mac", async () => {
@ -132,15 +132,15 @@ describe("PlainTextComposer", () => {
// Then it does NOT send a message on enter
await userEvent.type(textBox, "{enter}");
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
// Then it does NOT send a message on ctrl+enter
await userEvent.type(textBox, "{control>}{enter}{control/}");
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
// Then it does send a message on cmd+enter
await userEvent.type(textBox, "{meta>}{enter}{meta/}");
expect(onSend).toBeCalledTimes(1);
expect(onSend).toHaveBeenCalledTimes(1);
});
it("Should insert a newline character when shift enter is pressed when ctrlEnterToSend is false", async () => {
@ -155,7 +155,7 @@ describe("PlainTextComposer", () => {
await userEvent.type(textBox, inputWithShiftEnter);
// Then it does not send a message, but inserts a newline character
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
expect(textBox.innerHTML).toBe(expectedInnerHtml);
});
@ -172,7 +172,7 @@ describe("PlainTextComposer", () => {
await userEvent.type(textBox, keyboardInput);
// Then it does not send a message, but inserts a newline character
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
expect(textBox.innerHTML).toBe(expectedInnerHtml);
});
@ -188,7 +188,7 @@ describe("PlainTextComposer", () => {
await userEvent.type(textBox, "{enter}hello");
// Then it does not send a message, but inserts a newline character
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
expect(textBox).not.toContainHTML(enterThenTypeHtml);
});
@ -204,7 +204,7 @@ describe("PlainTextComposer", () => {
await userEvent.type(textBox, "{enter}");
// Then it does not send a message, but inserts a newline character
expect(onSend).toBeCalledTimes(0);
expect(onSend).toHaveBeenCalledTimes(0);
expect(textBox).not.toContainHTML(defaultEnterHtml);
});

View file

@ -88,10 +88,10 @@ describe("WysiwygComposer", () => {
});
// Then
await waitFor(() => expect(onChange).toBeCalledWith("foo bar"));
await waitFor(() => expect(onChange).toHaveBeenCalledWith("foo bar"));
});
it("Should call onSend when Enter is pressed ", async () => {
it("Should call onSend when Enter is pressed", async () => {
//When
fireEvent(
screen.getByRole("textbox"),
@ -101,18 +101,18 @@ describe("WysiwygComposer", () => {
);
// Then it sends a message
await waitFor(() => expect(onSend).toBeCalledTimes(1));
await waitFor(() => expect(onSend).toHaveBeenCalledTimes(1));
});
it("Should not call onSend when Shift+Enter is pressed ", async () => {
it("Should not call onSend when Shift+Enter is pressed", async () => {
//When
await userEvent.type(screen.getByRole("textbox"), "{shift>}{enter}");
// Then it sends a message
await waitFor(() => expect(onSend).toBeCalledTimes(0));
await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0));
});
it("Should not call onSend when ctrl+Enter is pressed ", async () => {
it("Should not call onSend when ctrl+Enter is pressed", async () => {
//When
// Using userEvent.type or .keyboard wasn't working as expected in the case of ctrl+enter
fireEvent(
@ -124,23 +124,23 @@ describe("WysiwygComposer", () => {
);
// Then it sends a message
await waitFor(() => expect(onSend).toBeCalledTimes(0));
await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0));
});
it("Should not call onSend when alt+Enter is pressed ", async () => {
it("Should not call onSend when alt+Enter is pressed", async () => {
//When
await userEvent.type(screen.getByRole("textbox"), "{alt>}{enter}");
// Then it sends a message
await waitFor(() => expect(onSend).toBeCalledTimes(0));
await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0));
});
it("Should not call onSend when meta+Enter is pressed ", async () => {
it("Should not call onSend when meta+Enter is pressed", async () => {
//When
await userEvent.type(screen.getByRole("textbox"), "{meta>}{enter}");
// Then it sends a message
await waitFor(() => expect(onSend).toBeCalledTimes(0));
await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0));
});
});
@ -172,7 +172,7 @@ describe("WysiwygComposer", () => {
);
// Then it does not send a message
await waitFor(() => expect(onSend).toBeCalledTimes(0));
await waitFor(() => expect(onSend).toHaveBeenCalledTimes(0));
fireEvent(
textbox,
@ -201,7 +201,7 @@ describe("WysiwygComposer", () => {
);
// Then it sends a message
await waitFor(() => expect(onSend).toBeCalledTimes(1));
await waitFor(() => expect(onSend).toHaveBeenCalledTimes(1));
});
});
@ -269,7 +269,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledTimes(0);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
it("Should moving when the composer is empty", async () => {
@ -281,7 +281,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.EditEvent,
event: mockEvent,
timelineRenderingType: defaultRoomContext.timelineRenderingType,
@ -316,7 +316,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledTimes(0);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
it("Should not moving when the content has changed", async () => {
@ -340,7 +340,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledTimes(0);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
it("Should moving up", async () => {
@ -366,7 +366,7 @@ describe("WysiwygComposer", () => {
// Then
await waitFor(() =>
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.EditEvent,
event: mockEvent,
timelineRenderingType: defaultRoomContext.timelineRenderingType,
@ -401,7 +401,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.EditEvent,
event: mockEvent,
timelineRenderingType: defaultRoomContext.timelineRenderingType,
@ -427,7 +427,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledTimes(0);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
it("Should not moving when the content has changed", async () => {
@ -451,7 +451,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledTimes(0);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
it("Should moving down", async () => {
@ -479,7 +479,7 @@ describe("WysiwygComposer", () => {
// Then
await waitFor(() =>
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.EditEvent,
event: mockEvent,
timelineRenderingType: defaultRoomContext.timelineRenderingType,
@ -516,7 +516,7 @@ describe("WysiwygComposer", () => {
});
// Then
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.EditEvent,
event: mockEvent,
timelineRenderingType: defaultRoomContext.timelineRenderingType,
@ -549,7 +549,7 @@ describe("WysiwygComposer", () => {
// Then
await waitFor(() =>
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: Action.EditEvent,
event: null,
timelineRenderingType: defaultRoomContext.timelineRenderingType,

View file

@ -66,8 +66,8 @@ describe("message", () => {
await sendMessage("", true, { roomContext: defaultRoomContext, mxClient: mockClient, permalinkCreator });
// Then
expect(mockClient.sendMessage).toBeCalledTimes(0);
expect(spyDispatcher).toBeCalledTimes(0);
expect(mockClient.sendMessage).toHaveBeenCalledTimes(0);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
it("Should not send message when there is no roomId", async () => {
@ -82,8 +82,8 @@ describe("message", () => {
});
// Then
expect(mockClient.sendMessage).toBeCalledTimes(0);
expect(spyDispatcher).toBeCalledTimes(0);
expect(mockClient.sendMessage).toHaveBeenCalledTimes(0);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
describe("calls client.sendMessage with", () => {
@ -108,7 +108,7 @@ describe("message", () => {
});
// Then
expect(mockClient.sendMessage).toBeCalledWith(expect.anything(), null, expect.anything());
expect(mockClient.sendMessage).toHaveBeenCalledWith(expect.anything(), null, expect.anything());
});
it("a null argument if SendMessageParams has relation but rel_type does not match THREAD_RELATION_TYPE.name", async () => {
// When
@ -123,7 +123,7 @@ describe("message", () => {
});
// Then
expect(mockClient.sendMessage).toBeCalledWith(expect.anything(), null, expect.anything());
expect(mockClient.sendMessage).toHaveBeenCalledWith(expect.anything(), null, expect.anything());
});
it("the event_id if SendMessageParams has relation and rel_type matches THREAD_RELATION_TYPE.name", async () => {
@ -139,7 +139,7 @@ describe("message", () => {
});
// Then
expect(mockClient.sendMessage).toBeCalledWith(expect.anything(), "valid_id", expect.anything());
expect(mockClient.sendMessage).toHaveBeenCalledWith(expect.anything(), "valid_id", expect.anything());
});
});
@ -158,8 +158,8 @@ describe("message", () => {
formatted_body: "<i><b>hello</b> world</i>",
msgtype: "m.text",
};
expect(mockClient.sendMessage).toBeCalledWith("myfakeroom", null, expectedContent);
expect(spyDispatcher).toBeCalledWith({ action: "message_sent" });
expect(mockClient.sendMessage).toHaveBeenCalledWith("myfakeroom", null, expectedContent);
expect(spyDispatcher).toHaveBeenCalledWith({ action: "message_sent" });
});
it("Should send reply to html message", async () => {
@ -180,7 +180,7 @@ describe("message", () => {
});
// Then
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: "reply_to_event",
event: null,
context: defaultRoomContext.timelineRenderingType,
@ -200,7 +200,7 @@ describe("message", () => {
},
},
};
expect(mockClient.sendMessage).toBeCalledWith("myfakeroom", null, expectedContent);
expect(mockClient.sendMessage).toHaveBeenCalledWith("myfakeroom", null, expectedContent);
});
it("Should scroll to bottom after sending a html message", async () => {
@ -213,7 +213,7 @@ describe("message", () => {
});
// Then
expect(spyDispatcher).toBeCalledWith({
expect(spyDispatcher).toHaveBeenCalledWith({
action: "scroll_to_bottom",
timelineRenderingType: defaultRoomContext.timelineRenderingType,
});
@ -224,7 +224,7 @@ describe("message", () => {
await sendMessage("🎉", false, { roomContext: defaultRoomContext, mxClient: mockClient, permalinkCreator });
// Then
expect(spyDispatcher).toBeCalledWith({ action: "effects.confetti" });
expect(spyDispatcher).toHaveBeenCalledWith({ action: "effects.confetti" });
});
});
@ -256,10 +256,10 @@ describe("message", () => {
await editMessage("", { roomContext: defaultRoomContext, mxClient: mockClient, editorStateTransfer });
// Then
expect(mockClient.sendMessage).toBeCalledTimes(0);
expect(mockClient.cancelPendingEvent).toBeCalledTimes(1);
expect(mockCreateRedactEventDialog).toBeCalledTimes(1);
expect(spyDispatcher).toBeCalledTimes(0);
expect(mockClient.sendMessage).toHaveBeenCalledTimes(0);
expect(mockClient.cancelPendingEvent).toHaveBeenCalledTimes(1);
expect(mockCreateRedactEventDialog).toHaveBeenCalledTimes(1);
expect(spyDispatcher).toHaveBeenCalledTimes(0);
});
it("Should do nothing if the content is unmodified", async () => {
@ -271,7 +271,7 @@ describe("message", () => {
});
// Then
expect(mockClient.sendMessage).toBeCalledTimes(0);
expect(mockClient.sendMessage).toHaveBeenCalledTimes(0);
});
it("Should send a message when the content is modified", async () => {
@ -301,8 +301,8 @@ describe("message", () => {
msgtype,
format,
};
expect(mockClient.sendMessage).toBeCalledWith(mockEvent.getRoomId(), null, expectedContent);
expect(spyDispatcher).toBeCalledWith({ action: "message_sent" });
expect(mockClient.sendMessage).toHaveBeenCalledWith(mockEvent.getRoomId(), null, expectedContent);
expect(spyDispatcher).toHaveBeenCalledWith({ action: "message_sent" });
});
});
});

View file

@ -47,7 +47,7 @@ describe("<DeviceDetailHeading />", () => {
expect({ container }).toMatchSnapshot();
});
it("renders device id as fallback when device has no display name ", () => {
it("renders device id as fallback when device has no display name", () => {
const { getByText } = render(
getComponent({
device: { ...device, display_name: undefined },

View file

@ -207,17 +207,6 @@ describe("<SessionManagerTab />", () => {
expect(container.getElementsByClassName("mx_Spinner").length).toBeTruthy();
});
it("removes spinner when device fetch fails", async () => {
mockClient.getDevices.mockRejectedValue({ httpStatus: 404 });
const { container } = render(getComponent());
expect(mockClient.getDevices).toHaveBeenCalled();
await act(async () => {
await flushPromises();
});
expect(container.getElementsByClassName("mx_Spinner").length).toBeFalsy();
});
it("removes spinner when device fetch fails", async () => {
// eat the expected error log
jest.spyOn(logger, "error").mockImplementation(() => {});
@ -760,7 +749,7 @@ describe("<SessionManagerTab />", () => {
expect(mockClient.getDevices).toHaveBeenCalled();
});
it("deletes a device when interactive auth is not required", async () => {
it("does not delete a device when interactive auth is not required", async () => {
const { getByTestId } = render(getComponent());
await act(async () => {