-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtests.js
181 lines (156 loc) · 5.78 KB
/
tests.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
178
179
180
181
// Console.Re API Tests
const testing = require('testing'),
configs = require('./config'), // edit ./config.js and change console.re channel name
disconnect = true;
if (process.env.CHANNEL) process.env.SERVER_CHANNEL = process.env.CHANNEL;
if (process.env.SERVER_CHANNEL === 'YOUR-CHANNEL-NAME') process.env.SERVER_CHANNEL = 'NodeTest';
const cl = require('./lib/connector.node.js').connect(
process.env.SERVER_DOMAIN,
process.env.SERVER_PORT,
process.env.SERVER_CHANNEL,
disconnect
);
const string = 'Test',
object = {
key1: 1,
key2: 2,
},
array = [1, 2, 3, 4, 5],
number = 43,
bbcodes = [
'[noparse][i]Italic[/i][/noparse]',
'[noparse][b]Bold[/b][/noparse]',
'[noparse][u]Underline[/u][/noparse]',
'[noparse][<color>]red|green|blue|yellow|orange|lime|white|black[/<color>][/noparse]',
'[noparse][size=<X>]1-20[/size][/noparse]',
];
function testConsoleClear(callback) {
testing.assert(console.re.clear(), 'testConsoleClear', callback);
testing.success('console.re.clear(); passed', callback);
}
function testConsoleTime(callback) {
testing.assert(console.re.time('run timer'), 'testConsoleTime', callback);
testing.success("console.re.time('run timer'); passed", callback);
}
function testConsoleLog(callback) {
testing.assert(console.re.log('This is a %s', string), 'testConsoleLog string', callback);
testing.success("console.re.log('This is a %s', string); passed");
testing.assert(console.re.log('This is an %s', object), 'testConsoleLog object', callback);
testing.success("console.re.log('This is an %s', object); passed");
testing.assert(console.re.log('This is an %s', array), 'testConsoleLog array', callback);
testing.success("console.re.log('This is an %s', array); passed");
testing.assert(console.re.log('This is a number %d', number), 'testConsoleLog number', callback);
testing.success("console.re.log('This is a number %d', number); passed");
testing.assert(
console.re.log('simple log output of [i]process.env[/i] %s', process.env),
'testConsoleLog process.env',
callback
);
testing.success("console.re.log('simple log output of [i]process.env[/i] %s', process.env); passed", callback);
}
function testConsoleInfo(callback) {
testing.assert(
console.re.info(
'using [[i]bbcodes[/i]] %s output can has in styles: [i]Italic[/i] [b]Bold[/b] [u]Underline[/u] and colors: [red]%s[/red] [green]%s[/green] [blue]%s[/blue] [yellow]%s[/yellow] [orange]%s[/orange] [lime]%s[/lime] [white]%s[/white] [black]%s[/black]',
bbcodes,
'red',
'green',
'blue',
'yellow',
'orange',
'lime',
'white',
'black'
),
'testConsoleInfo',
callback
);
testing.success(
"console.re.info('using [[i]bbcodes[/i]] %s output can has styles: [i]Italic[/i] [b]Bold[/b] [u]Underline[/u] and colors: [red]%s[/red] [green]%s[/green] [blue]%s[/blue] [yellow]%s[/yellow] [orange]%s[/orange] [lime]%s[/lime] [white]%s[/white] [black]%s[/black]', bbcodes, 'red', 'green', 'blue', 'yellow', 'orange', 'lime', 'white', 'black'); passed",
callback
);
}
function testConsoleCount(callback) {
testing.assert(console.re.count('counter one %d'), 'testConsoleCount', callback);
testing.success("console.re.count('counter one %d'); passed", callback);
}
function testConsoleDebug(callback) {
testing.assert(
console.re.debug(
'debug output for %s and %s',
{
key1: 'one',
key2: 'two',
key3: 'three',
},
[1, 2, 3, 'one', 'two', 'three']
),
'testConsoleDebug',
callback
);
testing.success(
"console.re.debug('debug output for %s and %s', {key1:'one',key2:'two',key3:'three'}, [1,2,3,'one','two','three']); passed",
callback
);
}
function testConsoleWarn(callback) {
testing.assert(console.re.warn('this is a warning level message'), 'testConsoleWarn', callback);
testing.success("console.re.warn('this is a warning level message'); passed", callback);
}
function testConsoleError(callback) {
testing.assert(
console.re.error('[red]output any error message using error level[/red]'),
'testConsoleError',
callback
);
testing.success("console.re.error('[red]output any error message using error level[/red]'); passed", callback);
}
function testConsoleTest(callback) {
testing.assert(
console.re.test('10 + 1', '[1,2,3,4,5,6]', "'text'", '1==1', "'ab'=='ba'"),
'testConsoleTest',
callback
);
testing.success('console.re.test("10 + 1","[1,2,3,4,5,6]","text","1==2","ab==ba"); passed', callback);
}
function testConsoleAssert(callback) {
testing.assert(console.re.assert(1 !== 1, '1!==1 Assertion Failure'), 'testConsoleAssert', callback);
testing.success("console.re.assert(1!==1, 'Assertion 1!==1 has Failure'); passed", callback);
}
function testConsoleTrace(callback) {
testing.assert(console.re.trace('Stack Trace output'), 'testConsoleTrace', callback);
testing.success("console.re.trace('Stack Trace output'); passed", callback);
}
function testConsoleTimeEnd(callback) {
testing.assert(console.re.timeEnd('run timer'), 'testConsoleTimeEnd', callback);
testing.success("console.re.timeEnd('run timer'); passed", callback);
}
function testResults(error, result) {
console.re.info('Console.Re API Tests %s', 'end');
if (error) {
testing.failure(`Console.Re API tests failed: ${error}`);
} else {
console.info('Console.Re API all tests passed');
}
}
function consoleReTests() {
console.re.info('Console.Re API Tests %s', 'started');
testing.run(
[
testConsoleClear,
testConsoleTime,
testConsoleLog,
testConsoleInfo,
testConsoleCount,
testConsoleDebug,
testConsoleWarn,
testConsoleError,
testConsoleTest,
testConsoleAssert,
testConsoleTrace,
testConsoleTimeEnd,
],
testResults
);
}
consoleReTests();