Closed roziscoding closed 2 weeks ago
const defaultHandler = spy(() => {});
const specificHandler = spy(() => {});
const commandGroup = new CommandGroup();
commandGroup.command("command", "_", defaultHandler, { prefix: "!" })
.addToScope({ type: "all_group_chats" }, specificHandler);
const bot = getBot();
bot.use(commands());
bot.use(commandGroup);
await bot.handleUpdate(
getDummyUpdate({
chatType: "group",
userInput: "!command",
}),
);
assertSpyCalls(defaultHandler, 0); // called once
assertSpyCalls(specificHandler, 1); // no call
Set up this little integration test and it's failing. Also tried in a real bot, and the default handler it's still taking prevalence.
Should I commit the test (+ the change to getDummyUpdate
to allow changing the chat type) to the pr?
I'll take a look now on why is it not properly fixing the issue
https://github.com/grammyjs/commands/pull/50#discussion_r1831294674 needs to be fixed before tests are useful
Fixes #49