Skip to content

Commit

Permalink
chore: fix grammatical and spelling errors in comments and tests (#1490)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkubej authored Jul 21, 2020
1 parent d1c9263 commit f8b49b8
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 40 deletions.
1 change: 1 addition & 0 deletions lib/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
18 changes: 10 additions & 8 deletions lib/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -163,7 +163,7 @@ module.exports = {
},

/**
* Get parsed query-string.
* Get parsed query string.
*
* @return {Object}
* @api public
Expand All @@ -176,7 +176,7 @@ module.exports = {
},

/**
* Set query-string as an object.
* Set query string as an object.
*
* @param {Object} obj
* @api public
Expand All @@ -199,7 +199,7 @@ module.exports = {
},

/**
* Set querystring.
* Set query string.
*
* @param {String} str
* @api public
Expand All @@ -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}
Expand Down Expand Up @@ -406,7 +406,7 @@ module.exports = {
},

/**
* Short-hand for:
* Shorthand for:
*
* this.protocol == 'https'
*
Expand All @@ -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.
*
Expand Down Expand Up @@ -495,6 +495,7 @@ module.exports = {
* @return {Object}
* @api private
*/

get accept() {
return this._accept || (this._accept = accepts(this.req));
},
Expand All @@ -505,6 +506,7 @@ module.exports = {
* @param {Object}
* @api private
*/

set accept(obj) {
this._accept = obj;
},
Expand Down Expand Up @@ -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.
Expand Down
7 changes: 5 additions & 2 deletions lib/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ module.exports = {
* @return {boolean}
* @api public
*/

has(field) {
return typeof this.res.hasHeader === 'function'
? this.res.hasHeader(field)
Expand All @@ -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:
Expand Down Expand Up @@ -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();
}
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion test/application/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion test/application/respond.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion test/application/use.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion test/context/onerror.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
6 changes: 3 additions & 3 deletions test/request/accepts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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, */*';
Expand All @@ -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/*';
Expand Down
2 changes: 1 addition & 1 deletion test/request/fresh.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions test/request/hostname.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]');
Expand Down
2 changes: 1 addition & 1 deletion test/request/length.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down
4 changes: 2 additions & 2 deletions test/request/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/request/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
});
Expand Down
20 changes: 9 additions & 11 deletions test/request/whatwg-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/response/attachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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'],
Expand Down
6 changes: 3 additions & 3 deletions test/response/writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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)
Expand All @@ -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();
Expand Down

0 comments on commit f8b49b8

Please sign in to comment.