Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 377e191

Browse files
author
Alun Turner
committed
test for action dispatch
1 parent 0282c14 commit 377e191

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/components/views/rooms/wysiwyg_composer/utils/message-test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import * as SlashCommands from "../../../../../../src/SlashCommands";
2929
import * as Commands from "../../../../../../src/editor/commands";
3030
import * as Reply from "../../../../../../src/utils/Reply";
3131
import { MatrixClientPeg } from "../../../../../../src/MatrixClientPeg";
32+
import { Action } from "../../../../../../src/dispatcher/actions";
3233

3334
describe("message", () => {
3435
const permalinkCreator = {
@@ -355,7 +356,7 @@ describe("message", () => {
355356
},
356357
);
357358

358-
it("if user enters invalid command and then sends it anyway, message is sent", async () => {
359+
it("if user enters invalid command and then sends it anyway", async () => {
359360
// mock out returning a true value for `shouldSendAnyway` to avoid rendering the modal
360361
jest.spyOn(Commands, "shouldSendAnyway").mockResolvedValue(true);
361362
const invalidCommandInput = "/badCommand";
@@ -366,11 +367,14 @@ describe("message", () => {
366367
permalinkCreator,
367368
});
368369

370+
// we expect the message to have been sent
371+
// and a composer focus action to have been dispatched
369372
expect(mockClient.sendMessage).toHaveBeenCalledWith(
370373
"myfakeroom",
371374
null,
372375
expect.objectContaining({ body: invalidCommandInput }),
373376
);
377+
expect(spyDispatcher).toHaveBeenCalledWith(expect.objectContaining({ action: Action.FocusAComposer }));
374378
});
375379

376380
it("if user enters invalid command and then does not send, return undefined", async () => {

0 commit comments

Comments
 (0)