summary refs log tree commit diff homepage
path: root/tests/Discord.test.ts
diff options
context:
space:
mode:
authordestruc7i0n <destruc7i0n@users.noreply.github.com>2022-01-03 16:08:32 -0500
committerdestruc7i0n <destruc7i0n@users.noreply.github.com>2022-01-03 16:08:32 -0500
commit3b0306b0f09d79426c117784092701e1a4d8133c (patch)
tree85d687f92776eaeb224bc30fac00eec304e858ef /tests/Discord.test.ts
parentadded debug for webhook ratelimit (diff)
downloadshulker-3b0306b0f09d79426c117784092701e1a4d8133c.tar.gz
shulker-3b0306b0f09d79426c117784092701e1a4d8133c.zip
added tests
Diffstat (limited to 'tests/Discord.test.ts')
-rw-r--r--tests/Discord.test.ts42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/Discord.test.ts b/tests/Discord.test.ts
new file mode 100644
index 0000000..400aa98
--- /dev/null
+++ b/tests/Discord.test.ts
@@ -0,0 +1,42 @@
+import Discord from '../src/Discord'
+
+import { defaultConfig } from './constants'
+
+describe('Discord', () => {
+  describe('replace mentions', () => {
+    test('does not replace mentions if config is disabled', async () => {
+      const discord = new Discord(defaultConfig)
+
+      const replacedMessage = await discord['replaceDiscordMentions']('hey @destruc7i0n#7070')
+      expect(replacedMessage).toBe('hey @destruc7i0n#7070')
+    })
+
+    // test('does replace mentions if config is enabled', async () => {
+    //   const discord = new Discord({...defaultConfig, ALLOW_USER_MENTIONS: true})
+    //   await discord.init()
+
+    //   const replacedMessage = await discord['replaceDiscordMentions']('hey @destruc7i0n#7070')
+    //   expect(replacedMessage).toBe('hey <@129277271843274752>')
+    // })
+
+    test('removes @everyone and @here if disabled', async () => {
+      const discord = new Discord({...defaultConfig, ALLOW_HERE_EVERYONE_MENTIONS: false})
+
+      const everyone = await discord['replaceDiscordMentions']('hey @everyone')
+      const here = await discord['replaceDiscordMentions']('hey @here')
+      
+      expect(everyone).toBe('hey @ everyone')
+      expect(here).toBe('hey @ here')
+    })
+
+    test('keeps @everyone and @here if enabled', async () => {
+      const discord = new Discord({...defaultConfig, ALLOW_HERE_EVERYONE_MENTIONS: true})
+
+      const everyone = await discord['replaceDiscordMentions']('hey @everyone')
+      const here = await discord['replaceDiscordMentions']('hey @here')
+      
+      expect(everyone).toBe('hey @everyone')
+      expect(here).toBe('hey @here')
+    })
+  })
+})
\ No newline at end of file