forked from forwardemail/superagent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoError.js
More file actions
28 lines (24 loc) · 661 Bytes
/
toError.js
File metadata and controls
28 lines (24 loc) · 661 Bytes
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
var request = require('../..')
, express = require('express')
, assert = require('better-assert')
, app = express()
, url = require('url');
app.get('/', function(req, res){
res.status(400).send('invalid json');
});
app.listen(8888);
describe('res.toError()', function(){
it('should return an Error', function(done){
request
.get('http://localhost:8888/')
.end(function(err, res){
var err = res.toError();
assert(err.status == 400);
assert(err.method == 'GET');
assert(err.path == '/');
assert(err.message == 'cannot GET / (400)');
assert(err.text == 'invalid json');
done();
});
})
})