Fix emoticon slash commands including stale buffers (#32928)
This commit is contained in:
@@ -11,14 +11,15 @@ import { Command } from "./command";
|
|||||||
import { successSync } from "./utils";
|
import { successSync } from "./utils";
|
||||||
import { CommandCategories } from "./interface";
|
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({
|
return new Command({
|
||||||
command,
|
command,
|
||||||
args: "<message>",
|
args: "<message>",
|
||||||
description,
|
description,
|
||||||
runFn: function (_cli, _roomId, _threadId, args) {
|
runFn: function (_cli, _roomId, _threadId, args) {
|
||||||
|
let message = prefix;
|
||||||
if (args) {
|
if (args) {
|
||||||
message = message + " " + args;
|
message += " " + args;
|
||||||
}
|
}
|
||||||
return successSync(ContentHelpers.makeTextMessage(message));
|
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 () => {
|
it("should match snapshot with args", async () => {
|
||||||
const { client, command } = setUpCommandTest(roomId, `/${commandName}`);
|
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,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user