1 |
import RestStringArgument from "@framework/arguments/RestStringArgument"; |
2 |
import { beforeEach, describe, expect, it } from "vitest"; |
3 |
import { createApplication } from "../../mocks/application.mock"; |
4 |
import { initialize } from "./ArgumentTestUtils"; |
5 |
|
6 |
describe("RestStringArgument", () => { |
7 |
createApplication(); |
8 |
let data: ReturnType<typeof initialize>; |
9 |
|
10 |
beforeEach(() => { |
11 |
data = initialize({ |
12 |
content: "test a b c d e f", |
13 |
userId: "1", |
14 |
guildId: "1", |
15 |
prefix: "!" |
16 |
}); |
17 |
}); |
18 |
|
19 |
it("should parse a rest string argument", async () => { |
20 |
const result = await RestStringArgument.performCast( |
21 |
data.context, |
22 |
data.content, |
23 |
data.argv, |
24 |
data.argv[2], |
25 |
1, |
26 |
"testarg", |
27 |
undefined, |
28 |
true |
29 |
); |
30 |
|
31 |
expect(result.value?.getRawValue()).toBe("b"); |
32 |
expect(result.value?.getValue()).toBe("b c d e f"); |
33 |
expect(result.error).toBeUndefined(); |
34 |
}); |
35 |
}); |