koa-lite/test/request/length.js

19 lines
426 B
JavaScript
Raw Normal View History

2014-07-06 08:43:14 +00:00
'use strict';
const request = require('../helpers/context').request;
const assert = require('assert');
2014-07-06 08:43:14 +00:00
describe('ctx.length', () => {
it('should return length in content-length', () => {
const req = request();
2014-07-06 08:43:14 +00:00
req.header['content-length'] = '10';
2017-05-11 03:30:32 +00:00
assert.equal(req.length, 10);
2015-10-12 20:36:41 +00:00
});
2014-07-06 08:43:14 +00:00
2017-04-20 02:43:06 +00:00
it('with no content-length present', () => {
const req = request();
2017-05-11 03:30:32 +00:00
assert.equal(req.length, undefined);
2015-10-12 20:36:41 +00:00
});
});