From 68253f67330ca0064af7d6447dcec68c60611d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=A3=E9=87=8C=E5=A5=BD=E8=84=8F=E4=B8=8D=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5?= <453491931@qq.com> Date: Mon, 4 Jul 2022 14:32:19 +0800 Subject: [PATCH] fix(lib/test/doc): fix jsdoc and typo (#146) --- .github/ISSUE_TEMPLATE.md | 4 ++-- API.md | 2 +- lib/layer.js | 2 +- lib/router.js | 5 ++--- test/lib/layer.js | 7 +++---- test/lib/router.js | 24 ++++++++++++------------ 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index cf73984..3a78e47 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -27,10 +27,10 @@ npm/yarn and version: #### Code sample: ```js diff --git a/API.md b/API.md index 9830750..2242e4e 100644 --- a/API.md +++ b/API.md @@ -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 diff --git a/lib/layer.js b/lib/layer.js index a696c3a..51265ab 100644 --- a/lib/layer.js +++ b/lib/layer.js @@ -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. diff --git a/lib/router.js b/lib/router.js index f3dfb76..8e2aaf3 100644 --- a/lib/router.js +++ b/lib/router.js @@ -65,7 +65,7 @@ function Router(opts = {}) { this.params = {}; this.stack = []; -}; +} /** * Create `router.verb()` methods, where *verb* is one of the HTTP verbs such @@ -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 @@ -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) { diff --git a/test/lib/layer.js b/test/lib/layer.js index ee3d4b5..77ca8eb 100644 --- a/test/lib/layer.js +++ b/test/lib/layer.js @@ -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()); @@ -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()); @@ -297,4 +296,4 @@ describe('Layer', function() { prefix.path.should.equal(false) }); }); -}); \ No newline at end of file +}); diff --git a/test/lib/router.js b/test/lib/router.js index f937365..5a7dccc 100644 --- a/test/lib/router.js +++ b/test/lib/router.js @@ -159,7 +159,7 @@ describe('Router', function () { }, nestedRouter.routes()); app.use(parentRouter.routes()); - app.should.be.ok; + app.should.be.ok(); done(); }); @@ -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(); }); @@ -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; }); @@ -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; }); @@ -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) => { @@ -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) => { @@ -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) => { @@ -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) => {