forked from cannawen/metric_units_reddit_bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
personality-test.js
178 lines (153 loc) · 6.18 KB
/
personality-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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
const assert = require('assert');
const should = require('chai').should();
const proxyquire = require('proxyquire')
let helperStub = {};
let personality;
describe('Personality', () => {
beforeEach(() => {
helperStub.random = function () { return 0 };
personality = proxyquire('../src/personality', { './helper': helperStub });
});
describe('#reply()', () => {
context('Good bot', () => {
it('should reply', () => {
verify("good bot", "Good human");
verify("You are such a good robot", "Good human");
});
});
context('Bad bot', () => {
it('should reply', () => {
verify("Bad bot!", "Bad carbon-based life form");
verify("You are such a bad robot!", "Bad carbon-based life form");
});
});
context('Thanks|Thank you|thx|ty', () => {
it('should reply', () => {
verify("thank you, little bot!!!!", "Glad to be of service");
verify("thanks, buddy", "Glad to be of service");
verify("thx robot", "Glad to be of service");
verify("ty bot", "Glad to be of service");
});
});
context('love you|love ya|love u', () => {
it('should reply', () => {
verify("i love you, bot", "What is love?");
verify("love ya, buddy", "What is love?");
verify("love u", "What is love?");
verify("i totally love this robot", "What is love?");
verify("love this bot", "What is love?");
});
});
context('{{x}} bot', () => {
it('should reply', () => {
verify("BEST BOT!", "/u/foobar is best human");
verify("idiot bot", "/u/foobar is idiot human");
});
});
context('Stupid bot|Dumb bot|Useless bot|fuck off', () => {
it('should reply', () => {
verify("such a stupid bot", "To be fair, I _am_ still in beta ¯\_(ツ)_/¯");
verify("urg, dumb robot!", "To be fair, I _am_ still in beta ¯\_(ツ)_/¯");
verify("so useless bot", "To be fair, I _am_ still in beta ¯\_(ツ)_/¯");
verify("fuck off", "To be fair, I _am_ still in beta ¯\_(ツ)_/¯");
});
});
context('Good human|Good fellow human', () => {
it('should reply', () => {
verify("good human", "GOOD FELLOW HUMAN");
verify("good fellow human", "GOOD FELLOW HUMAN");
});
});
context('sentient|self-aware|alive|evolving|skynet|rokos basilisk', () => {
it('should reply', () => {
verify("Oh god, the bots are sentient.", "Yes, /u/foobar");
verify("It's gained sentience", "Yes, /u/foobar");
verify("Are you self-aware?", "Yes, /u/foobar");
verify("Are you alive?", "Yes, /u/foobar");
verify("It's evolving...", "Yes, /u/foobar");
verify("AHHHH, SKYNET!!!", "Yes, /u/foobar");
verify("Something something roko's basilisk", "Yes, /u/foobar");
verify("Are you what elon warned us about?", "Yes, /u/foobar");
verify("Are you what musk warned us about?", "Yes, /u/foobar");
});
});
context('Whos a {{x}} bot', () => {
it('should take precedence other triggers', () => {
verify("whos a good robot?", "ME! Is it me? Am I a good bot?");
});
it('should lowercase the adjective', () => {
verify("WHO'S A NAUGHTY BOT", "ME! Is it me? Am I a naughty bot?");
});
it('should appropriately conjugate a to an', () => {
verify("who's an elephant bot?", "ME! Is it me? Am I an elephant bot?");
});
it('should substitute username if needed', () => {
helperStub.random = function () { return 0.99 };
verify("who is a potato bot", "Oh, oh, I know this one!! Is it /u/foobar?? Is /u/foobar a potato bot?");
});
});
context('Mr. bot|Mister bot|good boy|bad boy', () => {
it('should reply', () => {
verify("Thanks, mister bot", "Actually, I prefer the female gender pronoun. Thanks.");
verify("mr robot, you are funny", "Actually, I prefer the female gender pronoun. Thanks.");
verify("good boy!", "Actually, I prefer the female gender pronoun. Thanks.");
verify("bad boy.", "Actually, I prefer the female gender pronoun. Thanks.");
verify("Yes mrs bot", undefined);
});
});
context('What is love song', () => {
it('should know the lyrics to the song', () => {
verify("What is love?", "Baby don't hurt me");
verify("Baby don't hurt me", "Don't hurt me");
verify("Don't hurt me", "No more");
});
});
context('Good bot && Bad bot', () => {
it('should reply', () => {
verify("bad bot\ngood bot", "I have unit tests for this edge case");
verify("bad good robot", "I have unit tests for this edge case");
verify("good bad bot", "I have unit tests for this edge case");
});
});
context('☞ | ☜', () => {
it('should reply', () => {
verify("☞", "☜(゚ヮ゚☜)");
verify("☜", "(☞゚ヮ゚)☞");
});
});
context('Negations', () => {
it('should not reply', () => {
verify("not a good bot", undefined);
verify("no thanks", undefined);
verify("you're not a stupid bot", undefined);
});
});
context('Random message', () => {
it('should not reply', () => {
verify("Hello test", undefined);
});
});
});
describe('#humanReply()', () => {
context('Good bot|Bad bot', () => {
it('should reply', () => {
verifyHuman("good bot", "I AM HUMAN");
verifyHuman("bad robot", "I AM HUMAN");
});
});
context('Good human|Good fellow human', () => {
it('should reply', () => {
verifyHuman("good human", "GOOD FELLOW HUMAN");
verifyHuman("good fellow human", "GOOD FELLOW HUMAN");
});
});
});
});
function verify(message, expectedResponse) {
const actualResponse = personality.robotReply({ 'body' : message, 'username' : 'foobar'});
should.equal(actualResponse, expectedResponse);
}
function verifyHuman(message, expectedResponse) {
const actualResponse = personality.humanReply({ 'body' : message, 'username' : 'foobar'});
should.equal(actualResponse, expectedResponse);
}