-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhello_world.test.js
More file actions
120 lines (106 loc) · 3.42 KB
/
hello_world.test.js
File metadata and controls
120 lines (106 loc) · 3.42 KB
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
// var test = require('tape');
// var module = require('../lib/index.js');
// var HW = new module.HelloWorld();
// test('HellowWorld error - throw exception during construction', function(t) {
// var never = '';
// try {
// var HWuhoh = new module.HelloWorld('uhoh');
// never = 'neverland';
// } catch (err) {
// t.ok(err, 'expected error');
// }
// t.equals(never, '', 'constructor definitely throws');
// t.end();
// });
// test('HellowWorld error - throw type error during construction', function(t) {
// var never = '';
// try {
// var HWuhoh = new module.HelloWorld(24);
// never = 'neverland';
// } catch (err) {
// t.ok(err, 'expected error');
// t.equals(err.message, 'arg must be a string')
// }
// t.equals(never, '', 'constructor definitely throws');
// t.end();
// });
// test('HellowWorld error - invalid constructor', function(t) {
// var never = '';
// try {
// var HWuhoh = module.HelloWorld();
// never = 'neverland';
// } catch (err) {
// t.ok(err, 'expected error');
// t.equals(err.message, "Cannot call constructor as function, you need to use 'new' keyword");
// }
// t.equals(never, '', 'constructor definitely throws');
// t.end();
// });
// test('HellowWorld success - valid constructor', function(t) {
// var never = '';
// try {
// var HWyay = new module.HelloWorld('hello');
// never = 'neverland';
// } catch (err) {
// if (err) throw err;
// }
// t.equals(never, 'neverland', 'constructor definitely succeeds');
// t.end();
// });
// test('wave success', function(t) {
// var hello = HW.wave();
// t.equal(hello, 'howdy world', 'output of HelloWorld.wave');
// t.end();
// });
// test('shout success', function(t) {
// HW.shout('rawr', {}, function(err, shout) {
// if (err) throw err;
// t.equal(shout, 'rawr!');
// t.end();
// });
// });
// test('shout success - options.louder', function(t) {
// HW.shout('rawr', { louder: true }, function(err, shout) {
// if (err) throw err;
// t.equal(shout, 'rawr!!!!!');
// t.end();
// });
// });
// test('shout error - not enough rawr', function(t) {
// HW.shout('tiny moo', { louder: true }, function(err, shout) {
// t.ok(err, 'expected error');
// t.ok(err.message.indexOf('rawr all the time') > -1, 'rawrs all the time are way nicer');
// t.end();
// });
// });
// test('shout error - non string phrase', function(t) {
// HW.shout(4, {}, function(err, shout) {
// t.ok(err, 'expected error');
// t.ok(err.message.indexOf('phrase') > -1, 'proper error message');
// t.end();
// });
// });
// test('shout error - no options object', function(t) {
// HW.shout('rawr', true, function(err, shout) {
// t.ok(err, 'expected error');
// t.ok(err.message.indexOf('options') > -1, 'proper error message');
// t.end();
// });
// });
// test('shout error - options.louder non boolean', function(t) {
// HW.shout('rawr', { louder: 3 }, function(err, shout) {
// t.ok(err, 'expected error');
// t.ok(err.message.indexOf('louder') > -1, 'proper error message');
// t.end();
// });
// });
// // we have to try/catch since a missing callback results in a throw
// test('shout error - no callback', function(t) {
// try {
// HW.shout('rawr', {});
// } catch (err) {
// t.ok(err, 'expected error');
// t.ok(err.message.indexOf('callback') > -1, 'proper error message');
// t.end();
// }
// });