-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
81 lines (64 loc) · 3.29 KB
/
test.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
const phraseBlackList = require('./index')
// ---------------------------------------- //
// Banned phrases
// ---------------------------------------- //
let testResponse = (isCleanResult) => isCleanResult === true ? "Passed" : `Detected "${isCleanResult}"`
console.log("\nDefault banned phrases:", JSON.stringify(phraseBlackList.bannedContainment))
var testStrings = ['c0ck', 'sh1t', 'b1tch', 'wordyshit']
console.log("Below should all detect")
for(var i=0; i<testStrings.length; i++){
let isClean = phraseBlackList.isClean(testStrings[i])
console.log(`"${testStrings[i]}" : ${testResponse(isClean)}`)
}
var phrasesToBan = ["noob", "skiddie", "retard"]
console.log("\nBanning:", JSON.stringify(phrasesToBan))
phraseBlackList.BanPhrases(phrasesToBan)
console.log("Updated banned phrases:", JSON.stringify(phraseBlackList.bannedContainment))
var phrasesToUnban = ["noob", "skiddie"]
console.log("\nUnbanning:", JSON.stringify(phrasesToUnban))
phraseBlackList.UnbanPhrases(phrasesToUnban)
console.log("Updated banned phrases:", JSON.stringify(phraseBlackList.bannedContainment))
var phraseToBan = "idiot"
console.log("\nBanning single phrase:", phraseToBan)
phraseBlackList.BanPhrases(phraseToBan)
console.log("Updated banned phrases:", JSON.stringify(phraseBlackList.bannedContainment))
var phraseToUnban = "idiot"
console.log("\nUnbanning single phrase:", phraseToUnban)
phraseBlackList.UnbanPhrases(phraseToUnban)
console.log("Updated banned phrases:", JSON.stringify(phraseBlackList.bannedContainment))
// ---------------------------------------- //
// Banned words
// ---------------------------------------- //
console.log("\nDefault banned words:", JSON.stringify(phraseBlackList.bannedWords))
console.log("Below should all reject")
var testStrings = ['fag', ' fag', 'fag ', ' fag ', "FaG", "FAG"]
for(var i=0; i<testStrings.length; i++){
var isClean = phraseBlackList.isClean(testStrings[i])
console.log(`"${testStrings[i]}" : ${testResponse(isClean)}`)
}
console.log("\nBelow should all pass")
testStrings = ['fageot', 'fagit']
for(var i=0; i<testStrings.length; i++){
var isClean = phraseBlackList.isClean(testStrings[i])
console.log(`"${testStrings[i]}" : ${testResponse(isClean)}`)
}
console.log("\nTest ban/unban")
var phrasesToBan = ["noob", "skiddie", "retard"]
console.log("\nBanning:", JSON.stringify(phrasesToBan))
phraseBlackList.BanWords(phrasesToBan)
console.log("Updated banned words:", JSON.stringify(phraseBlackList.bannedWords))
var phrasesToUnban = ["noob", "skiddie"]
console.log("\nUnbanning:", JSON.stringify(phrasesToUnban))
phraseBlackList.UnbanWords(phrasesToUnban)
console.log("Updated banned words:", JSON.stringify(phraseBlackList.bannedWords))
var phraseToBan = "idiot"
console.log("\nBanning single word:", phraseToBan)
phraseBlackList.BanWords(phraseToBan)
console.log("Updated banned words:", JSON.stringify(phraseBlackList.bannedWords))
var phraseToUnban = "idiot"
console.log("\nUnbanning single word:", phraseToUnban)
phraseBlackList.UnbanWords(phraseToUnban)
console.log("Updated banned words:", JSON.stringify(phraseBlackList.bannedWords))
console.log("\nTranslating special characters")
var testTranslate = ["𝕙𝕖𝕔𝕜", "𝓱𝓮𝓬𝓴", "heck", "ˢˣᵉ", "$31@"]
testTranslate.forEach(phrase => console.log(`${phrase} = ${phraseBlackList.TranslateMaskChars(phrase)}`))