diff options
| author | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-28 18:41:51 -0400 |
|---|---|---|
| committer | IRONM00N <64110067+IRONM00N@users.noreply.github.com> | 2022-06-28 18:41:51 -0400 |
| commit | 627cbf6bebccb5bf2b36dea60e131cb53ce1e753 (patch) | |
| tree | 1ed2f67d93c4f43d100693cc39b37f1f05c3916e | |
| parent | 3070fbd47b127a8181be69ad98eb140a5f46cc21 (diff) | |
| download | tanzanite-627cbf6bebccb5bf2b36dea60e131cb53ce1e753.tar.gz tanzanite-627cbf6bebccb5bf2b36dea60e131cb53ce1e753.tar.bz2 tanzanite-627cbf6bebccb5bf2b36dea60e131cb53ce1e753.zip | |
create test files
119 files changed, 26 insertions, 4 deletions
diff --git a/src/lib/common/util/Arg.ts b/src/lib/common/util/Arg.ts index 325f821..d362225 100644 --- a/src/lib/common/util/Arg.ts +++ b/src/lib/common/util/Arg.ts @@ -5,7 +5,7 @@ import { type CommandMessage, type SlashMessage } from '#lib'; -import { Argument, type Flag, type ParsedValuePredicate } from 'discord-akairo'; +import { Argument, type Command, type Flag, type ParsedValuePredicate } from 'discord-akairo'; import { type Message } from 'discord.js'; /** @@ -17,8 +17,13 @@ import { type Message } from 'discord.js'; export async function cast<T extends ATC>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<ATCR<T>>; export async function cast<T extends KBAT>(type: T, message: CommandMessage | SlashMessage, phrase: string): Promise<BAT[T]>; export async function cast(type: AT | ATC, message: CommandMessage | SlashMessage, phrase: string): Promise<any>; -export async function cast(type: ATC | AT, message: CommandMessage | SlashMessage, phrase: string): Promise<any> { - return Argument.cast(type as any, message.client.commandHandler.resolver, message as Message, phrase); +export async function cast( + this: ThisType<Command>, + type: ATC | AT, + message: CommandMessage | SlashMessage, + phrase: string +): Promise<any> { + return Argument.cast.call(this, type as any, message.client.commandHandler.resolver, message as Message, phrase); } /** diff --git a/tests/arguments/abbreviatedNumber.test.ts b/tests/arguments/abbreviatedNumber.test.ts new file mode 100644 index 0000000..2cf326d --- /dev/null +++ b/tests/arguments/abbreviatedNumber.test.ts @@ -0,0 +1,10 @@ +import { expect, test } from 'vitest'; +import { abbreviatedNumber } from '../../src/arguments/abbreviatedNumber.js'; +import { CommandMessage } from '../../src/lib/index.js'; + +const message = {} as CommandMessage; + +test('empty string returns null', () => { + const res = abbreviatedNumber(message, ''); + expect(res).toBeNull(); +}); diff --git a/tests/arguments/contentWithDuration.test.ts b/tests/arguments/contentWithDuration.test.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/arguments/contentWithDuration.test.ts diff --git a/tests/arguments/discordEmoji.test.ts b/tests/arguments/discordEmoji.test.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/arguments/discordEmoji.test.ts diff --git a/tests/arguments/duration.test.ts b/tests/arguments/duration.test.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/arguments/duration.test.ts diff --git a/tests/arguments/durationSeconds.test.ts b/tests/arguments/durationSeconds.test.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/arguments/durationSeconds.test.ts diff --git a/tests/arguments/globalUser.test.ts b/tests/arguments/globalUser.test.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/arguments/globalUser.test.ts diff --git a/tests/arguments/messageLink.test.ts b/tests/arguments/messageLink.test.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/arguments/messageLink.test.ts diff --git a/tests/arguments/permission.test.ts b/tests/arguments/permission.test.ts new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/arguments/permission.test.ts |
