added more tests
This commit is contained in:
parent
9c18ec2d1f
commit
e6c0c378de
1 changed files with 51 additions and 8 deletions
|
@ -1,28 +1,71 @@
|
|||
import { parseArgs, Args } from "../src/utils/command.ts";
|
||||
import { assertEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts"
|
||||
import { assertEquals, assertNotEquals } from "https://deno.land/std@0.95.0/testing/asserts.ts"
|
||||
|
||||
const commandArgs: Args[] = [{
|
||||
// debugger
|
||||
const commandArgs: Args[] = [
|
||||
{
|
||||
name: "permaban",
|
||||
match: "flag",
|
||||
flag: "--permanent",
|
||||
defaultValue: true,
|
||||
}, {
|
||||
name: "user",
|
||||
match: "mention",
|
||||
}, {
|
||||
name: "reason",
|
||||
match: "rest",
|
||||
}];
|
||||
const messageArgs: string[] = ["<@!708544768342229012>","--permanent","bye","bye","Skyler"];
|
||||
const expectedResult = {
|
||||
defaultValue: "ree"
|
||||
}
|
||||
];
|
||||
|
||||
const messageArgs1: string[] = ["<@!708544768342229012>","--permanent","bye","bye","Skyler"];
|
||||
const expectedResult1 = {
|
||||
permaban: true,
|
||||
user: "708544768342229012",
|
||||
reason: ["bye","bye","Skyler"]
|
||||
}
|
||||
|
||||
Deno.test({
|
||||
name: "parse Args",
|
||||
name: "parse command arguments 1 (assertEquals)",
|
||||
fn: () => {
|
||||
const result = parseArgs(commandArgs,messageArgs);
|
||||
assertEquals(result, expectedResult)
|
||||
const result = parseArgs(commandArgs,messageArgs1);
|
||||
assertEquals(result, expectedResult1)
|
||||
},
|
||||
sanitizeOps: true,
|
||||
sanitizeResources: true,
|
||||
sanitizeExit: true,
|
||||
})
|
||||
|
||||
const messageArgs2: string[] = ["<@!708544768342229012>","bye","bye","Skyler"];
|
||||
const expectedResult2 = {
|
||||
permaban: true,
|
||||
user: "708544768342229012",
|
||||
reason: ["bye","bye","Skyler"]
|
||||
}
|
||||
|
||||
Deno.test({
|
||||
name: "parse command arguments 2 (assertEquals)",
|
||||
fn: () => {
|
||||
const result = parseArgs(commandArgs, messageArgs2);
|
||||
assertEquals(result, expectedResult2)
|
||||
},
|
||||
sanitizeOps: true,
|
||||
sanitizeResources: true,
|
||||
sanitizeExit: true,
|
||||
})
|
||||
|
||||
const messageArgs3: string[] = ["<@!708544768342229012>","bye","bye","Skyler"];
|
||||
const expectedResult3 = {
|
||||
permaban: false,
|
||||
user: "708544768342229012",
|
||||
reason: ["bye","bye","Skyler"]
|
||||
}
|
||||
|
||||
Deno.test({
|
||||
name: "parse command arguments 3 (assertNotEquals)",
|
||||
fn: () => {
|
||||
const result = parseArgs(commandArgs, messageArgs3);
|
||||
assertNotEquals(result, expectedResult3)
|
||||
},
|
||||
sanitizeOps: true,
|
||||
sanitizeResources: true,
|
||||
|
|
Loading…
Reference in a new issue