From a8bb3cc49b84e0fbf7ecb29de1274fc5a2587920 Mon Sep 17 00:00:00 2001 From: mierenmanz Date: Thu, 29 Apr 2021 19:34:16 +0200 Subject: [PATCH] add mention tests --- test/argsparser_test.ts | 49 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/test/argsparser_test.ts b/test/argsparser_test.ts index cc877c5..bd613f9 100644 --- a/test/argsparser_test.ts +++ b/test/argsparser_test.ts @@ -95,7 +95,7 @@ const expectedResult3 = { } Deno.test({ - name: 'parse command arguments 3 (assertNotEquals)', + name: 'parse command arguments default value (assertNotEquals)', fn: () => { const result = parseArgs(commandArgs, messageArgs3) assertNotEquals(result, expectedResult3) @@ -104,3 +104,50 @@ Deno.test({ sanitizeResources: true, sanitizeExit: true }) + + + +const commandArgs2: Args[] = [ + { + name: 'user', + match: 'mentionUser' + }, + { + name: 'channel', + match: 'mentionChannel' + }, + { + name: 'role', + match: 'mentionRole', + }, + { + name: 'reason', + match: 'rest', + defaultValue: 'ree' + } + +] + +const messageArgs4: string[] = [ + '<@!708544768342229012>', + 'bye', + '<#783319033730564098>', + '<@&836715188690092032>' +] +const expectedResult4 = { + channel: "783319033730564098", + role: "836715188690092032", + user: "708544768342229012", + reason: ["bye"] +} + +Deno.test({ + name: 'parse command arguments mentions (assertEquals)', + fn: () => { + const result = parseArgs(commandArgs2, messageArgs4) + assertEquals(result, expectedResult4) + }, + sanitizeOps: true, + sanitizeResources: true, + sanitizeExit: true +})