-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhello_async.test.js
More file actions
44 lines (39 loc) · 1.31 KB
/
hello_async.test.js
File metadata and controls
44 lines (39 loc) · 1.31 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
var test = require('tape');
var module = require('../lib/index.js');
test('success: prints loud busy world', function(t) {
module.hello_async({ louder: true }, function(err, result) {
if (err) throw err;
t.equal(result, '...threads are busy async bees...world!!!!');
t.end();
});
});
test('success: prints regular busy world', function(t) {
module.hello_async({ louder: false }, function(err, result) {
if (err) throw err;
t.equal(result, '...threads are busy async bees...world');
t.end();
});
});
test('fail: handles invalid louder value', function(t) {
module.hello_async({ louder: 'oops' }, function(err, result) {
t.ok(err, 'expected error');
t.ok(err.message.indexOf('option \'louder\' must be a boolean') > -1, 'expected error message');
t.end();
});
});
test('fail: handles invalid options value', function(t) {
module.hello_async('oops', function(err, result) {
t.ok(err, 'expected error');
t.ok(err.message.indexOf('first arg \'options\' must be an object') > -1, 'expected error message');
t.end();
});
});
test('fail: handles missing callback', function(t) {
try {
module.hello_async({ louder: 'oops' }, {});
} catch (err) {
t.ok(err, 'expected error');
t.ok(err.message.indexOf('callback') > -1, 'proper error message');
t.end();
}
});