2014-07-06 08:43:14 +00:00
|
|
|
|
2015-10-11 22:59:51 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-10-12 04:59:30 +00:00
|
|
|
const response = require('../helpers/context').response;
|
2015-10-05 18:23:47 +00:00
|
|
|
const assert = require('assert');
|
2018-06-25 02:34:15 +00:00
|
|
|
const util = require('util');
|
2014-07-06 08:43:14 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
describe('res.inspect()', () => {
|
|
|
|
describe('with no response.res present', () => {
|
|
|
|
it('should return null', () => {
|
2015-10-05 18:23:47 +00:00
|
|
|
const res = response();
|
2014-07-06 08:43:14 +00:00
|
|
|
res.body = 'hello';
|
|
|
|
delete res.res;
|
2017-05-11 03:30:32 +00:00
|
|
|
assert.equal(res.inspect(), null);
|
2018-06-25 02:34:15 +00:00
|
|
|
assert.equal(util.inspect(res), 'undefined');
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
|
|
|
});
|
2014-07-06 08:43:14 +00:00
|
|
|
|
2015-10-25 07:54:57 +00:00
|
|
|
it('should return a json representation', () => {
|
2015-10-05 18:23:47 +00:00
|
|
|
const res = response();
|
2014-07-06 08:43:14 +00:00
|
|
|
res.body = 'hello';
|
|
|
|
|
2018-06-25 02:34:15 +00:00
|
|
|
const expected = {
|
2014-07-06 08:43:14 +00:00
|
|
|
status: 200,
|
2014-10-01 12:12:20 +00:00
|
|
|
message: 'OK',
|
2014-07-06 08:43:14 +00:00
|
|
|
header: {
|
2018-06-25 02:34:15 +00:00
|
|
|
'content-type': 'text/plain; charset=utf-8',
|
|
|
|
'content-length': '5'
|
|
|
|
},
|
|
|
|
body: 'hello'
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(res.inspect(), expected);
|
|
|
|
assert.deepEqual(util.inspect(res), util.inspect(expected));
|
2015-10-12 20:36:41 +00:00
|
|
|
});
|
|
|
|
});
|