forked from klausrheum/hopeful
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.gs
64 lines (45 loc) · 1.41 KB
/
tests.gs
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
// test all functions
function testTester() {
testTracker();
}
function testTracker() {
testGetStudentByEmail();
testCreateStudentFullInfo();
//testCreateStudentFromSheet();
}
function logIt(msg, meta, dest_override) {
if (meta === undefined) meta = {tag: "???", "dest": "L"};
if (meta.dest === undefined) metadest = "L";
if (dest_override !== undefined) meta.dest = dest_override;
var output = {};
output.text = meta.tag + "> " + msg;
output.dest = meta.dest;
if (meta.dest == "L") {
Logger.log(output.text);
}
if (meta.dest == "C") {
console.info(output.text);
}
return output;
}
function testLogIt() {
var meta = {'tag': arguments.callee.name, "dest": "L"};
var m = "Message";
var answer, test;
test = "(m) => Logger(m)";
answer = logIt(m);
if ( answer.dest != "L" ) throw "(m) => Logger";
if ( answer.text != "???> Message" ) throw test;
test = "intentional fnTag";
answer = logIt(m, meta);
if ( answer.dest != "L" ) throw "(m) => Logger";
if ( answer.text != "testLogIt> Message" ) throw test;
test = "output to Logger";
answer = logIt(m, meta);
if ( answer.dest != "L" ) throw "(m) => Logger";
if ( answer.text != "testLogIt> Message" ) throw test;
test = "override to console";
answer = logIt(m, meta, "C");
if ( answer.dest != "C" ) throw "(m) => Logger";
if ( answer.text != "testLogIt> Message" ) throw test;
}