mirror of
https://github.com/vector-im/element-web.git
synced 2026-04-02 12:12:41 +02:00
Fix emoticon slash commands including stale buffers (#32928)
This commit is contained in:
parent
e78ad200a5
commit
ec47986ef5
@ -11,14 +11,15 @@ import { Command } from "./command";
|
||||
import { successSync } from "./utils";
|
||||
import { CommandCategories } from "./interface";
|
||||
|
||||
export function emoticon(command: string, description: TranslationKey, message: string): Command {
|
||||
export function emoticon(command: string, description: TranslationKey, prefix: string): Command {
|
||||
return new Command({
|
||||
command,
|
||||
args: "<message>",
|
||||
description,
|
||||
runFn: function (_cli, _roomId, _threadId, args) {
|
||||
let message = prefix;
|
||||
if (args) {
|
||||
message = message + " " + args;
|
||||
message += " " + args;
|
||||
}
|
||||
return successSync(ContentHelpers.makeTextMessage(message));
|
||||
},
|
||||
|
||||
@ -20,6 +20,11 @@ describe.each(["shrug", "tableflip", "unflip", "lenny"])("/%s", (commandName: st
|
||||
it("should match snapshot with args", async () => {
|
||||
const { client, command } = setUpCommandTest(roomId, `/${commandName}`);
|
||||
|
||||
await expect(command.run(client, roomId, null, "this is a test message").promise).resolves.toMatchSnapshot();
|
||||
const initialResult = await command.run(client, roomId, null, "this is a test message").promise;
|
||||
expect(initialResult).toMatchSnapshot();
|
||||
// We run this twice to ensure it doesn't stack the buffer
|
||||
await expect(command.run(client, roomId, null, "this is a test message").promise).resolves.toEqual(
|
||||
initialResult,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user