/[sudobot]/trunk/tests/framework/arguments/StringArgument.test.ts
ViewVC logotype

Contents of /trunk/tests/framework/arguments/StringArgument.test.ts

Parent Directory Parent Directory | Revision Log Revision Log


Revision 575 - (show annotations)
Mon Jul 29 17:59:26 2024 UTC (8 months ago) by rakinar2
File MIME type: application/typescript
File size: 1469 byte(s)
chore: add trunk
1 import { faker } from "@faker-js/faker";
2 import StringArgument from "@framework/arguments/StringArgument";
3 import { beforeEach, describe, expect, it } from "vitest";
4 import { createApplication } from "../../mocks/application.mock";
5 import { initialize } from "./ArgumentTestUtils";
6
7 describe("StringArgument", () => {
8 createApplication();
9 let data: ReturnType<typeof initialize>;
10
11 beforeEach(() => {
12 data = initialize({
13 content: faker.lorem.words(5),
14 userId: "1",
15 guildId: "1",
16 prefix: "!"
17 });
18 });
19
20 it("should parse a string argument", async () => {
21 const arg1 = await StringArgument.performCast(
22 data.context,
23 data.content,
24 data.argv,
25 data.argv[1],
26 0,
27 "testarg",
28 undefined,
29 true
30 );
31 const arg3 = await StringArgument.performCast(
32 data.context,
33 data.content,
34 data.argv,
35 data.argv[3],
36 2,
37 "testarg3",
38 undefined,
39 true
40 );
41
42 expect(arg1.value?.getRawValue()).toBe(data.argv[1]);
43 expect(arg1.value?.getValue()).toBe(data.argv[1]);
44 expect(arg1.error).toBeUndefined();
45
46 expect(arg3.value?.getRawValue()).toBe(data.argv[3]);
47 expect(arg3.value?.getValue()).toBe(data.argv[3]);
48 expect(arg3.error).toBeUndefined();
49 });
50 });

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26