koa-lite/test/response/message.js

32 lines
770 B
JavaScript
Raw Permalink Normal View History

'use strict';
2017-05-11 03:30:32 +00:00
const assert = require('assert');
const response = require('../helpers/context').response;
describe('res.message', () => {
it('should return the response status message', () => {
const res = response();
res.status = 200;
2017-05-11 03:30:32 +00:00
assert.equal(res.message, 'OK');
2015-10-12 20:36:41 +00:00
});
describe('when res.message not present', () => {
it('should look up in statuses', () => {
const res = response();
res.res.statusCode = 200;
2017-05-11 03:30:32 +00:00
assert.equal(res.message, 'OK');
2015-10-12 20:36:41 +00:00
});
});
});
describe('res.message=', () => {
it('should set response status message', () => {
const res = response();
res.status = 200;
res.message = 'ok';
2017-05-11 03:30:32 +00:00
assert.equal(res.res.statusMessage, 'ok');
assert.equal(res.inspect().message, 'ok');
2015-10-12 20:36:41 +00:00
});
});