e8f79d43f9
closes #517 add index test for Application add app.toJSON test add test for app.inspect() add tests for app.use() add tests for app.onerror() add tests for app.respond() add tests for app.context() add tests for app.request() add tests for app.response refactor for non-existence of test/app...js no need for *.js use helpers/ dir for non-tests
37 lines
773 B
JavaScript
37 lines
773 B
JavaScript
|
|
'use strict';
|
|
|
|
const context = require('../helpers/context');
|
|
|
|
describe('ctx.toJSON()', function(){
|
|
it('should return a json representation', function(){
|
|
const ctx = context();
|
|
|
|
ctx.req.method = 'POST';
|
|
ctx.req.url = '/items';
|
|
ctx.req.headers['content-type'] = 'text/plain';
|
|
ctx.status = 200;
|
|
ctx.body = '<p>Hey</p>';
|
|
|
|
const obj = JSON.parse(JSON.stringify(ctx));
|
|
const req = obj.request;
|
|
const res = obj.response;
|
|
|
|
req.should.eql({
|
|
method: 'POST',
|
|
url: '/items',
|
|
header: {
|
|
'content-type': 'text/plain'
|
|
}
|
|
});
|
|
|
|
res.should.eql({
|
|
status: 200,
|
|
message: 'OK',
|
|
header: {
|
|
'content-type': 'text/html; charset=utf-8',
|
|
'content-length': '10'
|
|
}
|
|
});
|
|
})
|
|
})
|