Skip to content

Commit

Permalink
fix(lib/test/doc): fix jsdoc and typo (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-itsheng committed Jul 4, 2022
1 parent c6a8fc8 commit 68253f6
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ npm/yarn and version:
#### Code sample:

<!--
Provide a code sapmle with THE MINIMUM amount of code to reproduce your issue.
Provide a code sample with THE MINIMUM amount of code to reproduce your issue.
If you cannot provide a succinct example, please create a small test app that exhibits
the issue you're experiencing. If you cannot provide this, your issue may not be
able to be reproduced and thus, we will be unabled to address it.
able to be reproduced and thus, we will be unable to address it.
-->

```js
Expand Down
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ as `router.get()` or `router.post()`.
Match URL patterns to callback functions or controller actions using `router.verb()`,
where **verb** is one of the HTTP verbs such as `router.get()` or `router.post()`.

Additionaly, `router.all()` can be used to match against all methods.
Additionally, `router.all()` can be used to match against all methods.

```javascript
router
Expand Down
2 changes: 1 addition & 1 deletion lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Layer(path, methods, middleware, opts = {}) {

this.path = path;
this.regexp = pathToRegexp(path, this.paramNames, this.opts);
};
}

/**
* Returns whether request `path` matches route.
Expand Down
5 changes: 2 additions & 3 deletions lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function Router(opts = {}) {

this.params = {};
this.stack = [];
};
}

/**
* Create `router.verb()` methods, where *verb* is one of the HTTP verbs such
Expand All @@ -74,7 +74,7 @@ function Router(opts = {}) {
* Match URL patterns to callback functions or controller actions using `router.verb()`,
* where **verb** is one of the HTTP verbs such as `router.get()` or `router.post()`.
*
* Additionaly, `router.all()` can be used to match against all methods.
* Additionally, `router.all()` can be used to match against all methods.
*
* ```javascript
* router
Expand Down Expand Up @@ -492,7 +492,6 @@ Router.prototype.allowedMethods = function (options = {}) {
* @param {Function=} middleware You may also pass multiple middleware.
* @param {Function} callback
* @returns {Router}
* @private
*/

Router.prototype.all = function (name, path, middleware) {
Expand Down
7 changes: 3 additions & 4 deletions test/lib/layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
const Koa = require('koa');
const http = require('http');
const request = require('supertest');
const should = require('should');
const Router = require('../../lib/router');
const Layer = require('../../lib/layer');

describe('Layer', function() {
it('composes multiple callbacks/middlware', function(done) {
it('composes multiple callbacks/middleware', function(done) {
const app = new Koa();
const router = new Router();
app.use(router.routes());
Expand Down Expand Up @@ -120,7 +119,7 @@ describe('Layer', function() {
});
});

it('populates ctx.captures with regexp captures include undefiend', function(done) {
it('populates ctx.captures with regexp captures include undefined', function(done) {
const app = new Koa();
const router = new Router();
app.use(router.routes());
Expand Down Expand Up @@ -297,4 +296,4 @@ describe('Layer', function() {
prefix.path.should.equal(false)
});
});
});
});
24 changes: 12 additions & 12 deletions test/lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ describe('Router', function () {
}, nestedRouter.routes());

app.use(parentRouter.routes());
app.should.be.ok;
app.should.be.ok();
done();
});

Expand Down Expand Up @@ -865,7 +865,7 @@ describe('Router', function () {
.end(function (err, res) {
if (err) return done(err);
res.header.should.have.property('allow', 'HEAD, GET');
let allowHeaders = res.res.rawHeaders.filter((item) => item == 'Allow');
let allowHeaders = res.res.rawHeaders.filter((item) => item === 'Allow');
expect(allowHeaders.length).to.eql(1);
done();
});
Expand Down Expand Up @@ -1567,7 +1567,7 @@ describe('Router', function () {
})

it('generates URL for given route name without params and query params', function (done) {
var router = new Router();
const router = new Router();
router.get('books', '/books', function (ctx) {
ctx.status = 204;
});
Expand All @@ -1592,7 +1592,7 @@ describe('Router', function () {


it('generates URL for given route name without params and query params', function (done) {
var router = new Router();
const router = new Router();
router.get('category', '/category', function (ctx) {
ctx.status = 204;
});
Expand Down Expand Up @@ -2069,8 +2069,8 @@ describe('Router', function () {


it('populates ctx.params correctly for router prefix (including use)', function (done) {
var app = new Koa();
var router = new Router({ prefix: '/:category' });
const app = new Koa();
const router = new Router({ prefix: '/:category' });
app.use(router.routes());
router
.use((ctx, next) => {
Expand All @@ -2095,8 +2095,8 @@ describe('Router', function () {
});

it('populates ctx.params correctly for more complex router prefix (including use)', function (done) {
var app = new Koa();
var router = new Router({ prefix: '/:category/:color' });
const app = new Koa();
const router = new Router({ prefix: '/:category/:color' });
app.use(router.routes());
router
.use((ctx, next) => {
Expand Down Expand Up @@ -2124,8 +2124,8 @@ describe('Router', function () {
});

it('populates ctx.params correctly for dynamic and static prefix (including async use)', function (done) {
var app = new Koa();
var router = new Router({ prefix: '/:ping/pong' });
const app = new Koa();
const router = new Router({ prefix: '/:ping/pong' });
app.use(router.routes());
router
.use(async (ctx, next) => {
Expand All @@ -2150,8 +2150,8 @@ describe('Router', function () {
});

it('populates ctx.params correctly for static prefix', function (done) {
var app = new Koa();
var router = new Router({ prefix: '/all' });
const app = new Koa();
const router = new Router({ prefix: '/all' });
app.use(router.routes());
router
.use((ctx, next) => {
Expand Down

0 comments on commit 68253f6

Please sign in to comment.