blob: 400aa98885628e3c7cda40c4b46393700787b2c7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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')
})
})
})
|