-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy patherror.js
More file actions
55 lines (42 loc) · 1.06 KB
/
error.js
File metadata and controls
55 lines (42 loc) · 1.06 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
var test = require('tape');
var WebSocket = require('ws');
var pull = require('pull-stream');
var ws = require('../');
var server = require('./server')()
//connect to a server that does not exist, and check that it errors.
//should pass the error to both sides of the stream.
test('test error', function (t) {
var _err
pull(
pull.values(['x', 'y', 'z']),
pull.through(null, function (err) {
if(_err) {
t.strictEqual(err, _err);
t.end();
}
_err = err
}),
ws(new WebSocket('ws://localhost:34897/' + Math.random())),
pull.collect(function (err) {
if(_err) {
t.strictEqual(err, _err);
t.end();
}
_err = err
})
)
})
//connect to a server that does not exist, and check that it errors.
//should pass the error to both sides of the stream.
test('test error', function (t) {
var _err
ws(new WebSocket('ws://localhost:34897/' + Math.random()),
{onConnect: function (err) {
t.ok(err)
t.end()
}})
})
test('close', function (t) {
server.close()
t.end()
})