mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-01 08:20:08 +00:00
I prefer semicolors, they also help avoiding certain pitfalls in JavaScript/TypeScript, such as the following code sample: ```js const xyz = "test" (something.else as string) = "another" ``` This results in a TypeError: "test" is not a function, this is because js thinks we are trying to call the string "test" as a function. To fix this it requires a `;` somewhere before the `(`, such as `;(something ... ` which in my opinion is ugly and less clean overall.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { use as chaiUse, expect } from 'chai';
|
|
import chaiAsPromised from 'chai-as-promised';
|
|
import { describe } from 'mocha';
|
|
import { e2eCache, rest } from './utils.js';
|
|
|
|
chaiUse(chaiAsPromised);
|
|
|
|
describe('Typings', () => {
|
|
it('Trigger Typing Indication', async () => {
|
|
await rest.triggerTypingIndicator(e2eCache.channel.id);
|
|
});
|
|
});
|
|
|
|
describe('Commands', () => {
|
|
it('Upsert global commands', async () => {
|
|
await rest.upsertGlobalApplicationCommands([
|
|
{
|
|
name: 'ping',
|
|
description: 'Ping the bot',
|
|
},
|
|
]);
|
|
|
|
const cmds = await rest.getGlobalApplicationCommands();
|
|
const created = cmds.find((cmd) => cmd.name === 'ping' && cmd.description === 'Ping the bot');
|
|
expect(!!created?.id).to.be.true;
|
|
|
|
const made = await rest.getGlobalApplicationCommand(created!.id);
|
|
expect(created?.name).to.be.equal(made.name);
|
|
expect(created?.description).to.be.equal(made.description);
|
|
|
|
const edited = await rest.editGlobalApplicationCommand(created!.id, { name: 'pong', description: 'edited description' });
|
|
expect(edited.name).to.be.equal('pong');
|
|
expect(edited.name).to.not.be.equal(made.name);
|
|
expect(edited.description).to.be.equal('edited description');
|
|
expect(edited.description).to.not.be.equal(made.description);
|
|
|
|
await rest.deleteGlobalApplicationCommand(created!.id);
|
|
|
|
await expect(rest.getGlobalApplicationCommand(created!.id)).to.eventually.be.rejected;
|
|
});
|
|
});
|