未验证 提交 f8b49b85 编写于 作者: M Matt Kubej 提交者: GitHub

chore: fix grammatical and spelling errors in comments and tests (#1490)

上级 d1c92638
......@@ -278,4 +278,5 @@ function respond(ctx) {
* Make HttpError available to consumers of the library so that consumers don't
* have a direct dependency upon `http-errors`
*/
module.exports.HttpError = HttpError;
......@@ -146,7 +146,7 @@ module.exports = {
},
/**
* Set pathname, retaining the query-string when present.
* Set pathname, retaining the query string when present.
*
* @param {String} path
* @api public
......@@ -163,7 +163,7 @@ module.exports = {
},
/**
* Get parsed query-string.
* Get parsed query string.
*
* @return {Object}
* @api public
......@@ -176,7 +176,7 @@ module.exports = {
},
/**
* Set query-string as an object.
* Set query string as an object.
*
* @param {Object} obj
* @api public
......@@ -199,7 +199,7 @@ module.exports = {
},
/**
* Set querystring.
* Set query string.
*
* @param {String} str
* @api public
......@@ -216,7 +216,7 @@ module.exports = {
},
/**
* Get the search string. Same as the querystring
* Get the search string. Same as the query string
* except it includes the leading ?.
*
* @return {String}
......@@ -406,7 +406,7 @@ module.exports = {
},
/**
* Short-hand for:
* Shorthand for:
*
* this.protocol == 'https'
*
......@@ -422,7 +422,7 @@ module.exports = {
* When `app.proxy` is `true`, parse
* the "X-Forwarded-For" ip address list.
*
* For example if the value were "client, proxy1, proxy2"
* For example if the value was "client, proxy1, proxy2"
* you would receive the array `["client", "proxy1", "proxy2"]`
* where "proxy2" is the furthest down-stream.
*
......@@ -495,6 +495,7 @@ module.exports = {
* @return {Object}
* @api private
*/
get accept() {
return this._accept || (this._accept = accepts(this.req));
},
......@@ -505,6 +506,7 @@ module.exports = {
* @param {Object}
* @api private
*/
set accept(obj) {
this._accept = obj;
},
......@@ -607,7 +609,7 @@ module.exports = {
/**
* Check if the incoming request contains the "Content-Type"
* header field, and it contains any of the give mime `type`s.
* header field and if it contains any of the given mime `type`s.
* If there is no request body, `null` is returned.
* If there is no content type, `false` is returned.
* Otherwise, it returns the first `type` that matches.
......
......@@ -433,6 +433,7 @@ module.exports = {
* @return {boolean}
* @api public
*/
has(field) {
return typeof this.res.hasHeader === 'function'
? this.res.hasHeader(field)
......@@ -441,7 +442,7 @@ module.exports = {
},
/**
* Set header `field` to `val`, or pass
* Set header `field` to `val` or pass
* an object of header fields.
*
* Examples:
......@@ -564,8 +565,9 @@ module.exports = {
},
/**
* Flush any set headers, and begin the body
* Flush any set headers and begin the body
*/
flushHeaders() {
this.res.flushHeaders();
}
......@@ -577,6 +579,7 @@ module.exports = {
* @return {Object}
* @api public
*/
/* istanbul ignore else */
if (util.inspect.custom) {
module.exports[util.inspect.custom] = module.exports.inspect;
......
......@@ -66,7 +66,7 @@ describe('app.onerror(err)', () => {
assert(msg === '\n Foo\n');
});
it('should use err.toString() instad of err.stack', () => {
it('should use err.toString() instead of err.stack', () => {
const app = new Koa();
app.env = 'dev';
......
......@@ -238,7 +238,7 @@ describe('app.respond', () => {
});
});
describe('when no middleware are present', () => {
describe('when no middleware is present', () => {
it('should 404', () => {
const app = new Koa();
......
......@@ -98,7 +98,7 @@ describe('app.use(fn)', () => {
.expect('generator');
});
it('should throw error for non function', () => {
it('should throw error for non-function', () => {
const app = new Koa();
[null, undefined, 0, false, 'not a function'].forEach(v => {
......
......@@ -239,7 +239,7 @@ describe('ctx.onerror(err)', () => {
});
describe('when non-error thrown', () => {
it('should response non-error thrown message', () => {
it('should respond with non-error thrown message', () => {
const app = new Koa();
app.use((ctx, next) => {
......
......@@ -62,7 +62,7 @@ describe('ctx.accepts(types)', () => {
});
});
describe('when present in Accept as an exact match', () => {
describe('when value present in Accept is an exact match', () => {
it('should return the type', () => {
const ctx = context();
ctx.req.headers.accept = 'text/plain, text/html';
......@@ -71,7 +71,7 @@ describe('ctx.accepts(types)', () => {
});
});
describe('when present in Accept as a type match', () => {
describe('when value present in Accept is a type match', () => {
it('should return the type', () => {
const ctx = context();
ctx.req.headers.accept = 'application/json, */*';
......@@ -81,7 +81,7 @@ describe('ctx.accepts(types)', () => {
});
});
describe('when present in Accept as a subtype match', () => {
describe('when value present in Accept is a subtype match', () => {
it('should return the type', () => {
const ctx = context();
ctx.req.headers.accept = 'application/json, text/*';
......
......@@ -36,7 +36,7 @@ describe('ctx.fresh', () => {
});
});
describe('and etag do not match', () => {
describe('and etag does not match', () => {
it('should return false', () => {
const ctx = context();
ctx.status = 200;
......
......@@ -31,13 +31,13 @@ describe('req.hostname', () => {
assert.equal(req.hostname, '[::1]');
});
it('should parse localhost with non special schema port', () => {
it('should parse localhost with non-special schema port', () => {
const req = request();
req.header.host = '[::1]:1337';
assert.equal(req.hostname, '[::1]');
});
it('should reduce IPv6 with non special schema port, as hostname', () => {
it('should reduce IPv6 with non-special schema port as hostname', () => {
const req = request();
req.header.host = '[2001:cdba:0000:0000:0000:0000:3257:9652]:1337';
assert.equal(req.hostname, '[2001:cdba::3257:9652]');
......
......@@ -11,7 +11,7 @@ describe('ctx.length', () => {
assert.equal(req.length, 10);
});
it('with no content-length present', () => {
it('should return undefined with no content-length present', () => {
const req = request();
assert.equal(req.length, undefined);
});
......
......@@ -18,14 +18,14 @@ describe('ctx.query', () => {
});
});
it('should return a parsed query-string', () => {
it('should return a parsed query string', () => {
const ctx = context({ url: '/?page=2' });
assert.equal(ctx.query.page, '2');
});
});
describe('ctx.query=', () => {
it('should stringify and replace the querystring and search', () => {
it('should stringify and replace the query string and search', () => {
const ctx = context({ url: '/store/shoes' });
ctx.query = { page: 2, color: 'blue' };
assert.equal(ctx.url, '/store/shoes?page=2&color=blue');
......
......@@ -11,7 +11,7 @@ describe('req.type', () => {
assert.equal(req.type, 'text/html');
});
it('with no host present', () => {
it('should return empty string with no host present', () => {
const req = request();
assert.equal(req.type, '');
});
......
......@@ -5,18 +5,16 @@ const request = require('../helpers/context').request;
const assert = require('assert');
describe('req.URL', () => {
describe('should not throw when', () => {
it('host is void', () => {
// Accessing the URL should not throw.
request().URL;
});
it('should not throw when host is void', () => {
// Accessing the URL should not throw.
request().URL;
});
it('header.host is invalid', () => {
const req = request();
req.header.host = 'invalid host';
// Accessing the URL should not throw.
req.URL;
});
it('should not throw when header.host is invalid', () => {
const req = request();
req.header.host = 'invalid host';
// Accessing the URL should not throw.
req.URL;
});
it('should return empty object when invalid', () => {
......
......@@ -24,7 +24,7 @@ describe('ctx.attachment([filename])', () => {
});
});
describe('when given a no-ascii filename', () => {
describe('when given a non-ascii filename', () => {
it('should set the encodeURI filename param', () => {
const ctx = context();
ctx.attachment('path/to/include-no-ascii-char-中文名-ok.png');
......@@ -168,7 +168,7 @@ describe('contentDisposition(filename, options)', () => {
'inline');
});
it('should create a header with inline type & filename', () => {
it('should create a header with inline type and filename', () => {
const ctx = context();
ctx.attachment('plans.pdf', { type: 'inline' });
assert.equal(ctx.response.header['content-disposition'],
......
......@@ -21,7 +21,7 @@ describe('res.writable', () => {
setTimeout(() => client.end(), 100);
}
it('should always writable and response all requests', done => {
it('should always be writable and respond to all requests', done => {
const app = new Koa();
let count = 0;
app.use(ctx => {
......@@ -50,7 +50,7 @@ describe('res.writable', () => {
});
}
it('should not writable', done => {
it('should not be writable', done => {
const app = new Koa();
app.use(ctx => {
sleep(1000)
......@@ -77,7 +77,7 @@ describe('res.writable', () => {
}, 100);
}
it('should not writable', done => {
it('should not be writable', done => {
const app = new Koa();
app.use(ctx => {
ctx.res.end();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册