diff --git a/lib/api_router.js b/lib/api_router.js index 4afc4ae9e6..b452d60666 100644 --- a/lib/api_router.js +++ b/lib/api_router.js @@ -1,11 +1,11 @@ const Router = require('@koa/router'); const router = new Router(); -const maintainer = require('./maintainer'); router.get('/routes/:name?', (ctx) => { const result = {}; let counter = 0; + const maintainer = require('./maintainer'); Object.keys(maintainer).forEach((i) => { const path = i; const top = path.split('/')[1]; diff --git a/lib/maintainer.js b/lib/maintainer.js index 99edd32c35..610215d531 100644 --- a/lib/maintainer.js +++ b/lib/maintainer.js @@ -27,7 +27,7 @@ for (const dir in maintainerPath) { throw Error(`No maintainer in "${dir}".`); } for (const author of Object.values(routes)) { - if (typeof author === 'string') { + if (!Array.isArray(author)) { throw Error(`Maintainers' name should be an array in "${dir}".`); } // check for [], [''] or ['Someone', ''] diff --git a/test/router.js b/test/router.js index f62516341b..5cbe816a78 100644 --- a/test/router.js +++ b/test/router.js @@ -98,7 +98,7 @@ describe('router', () => { }, message: 'request returned 1 route', }); - }); + }, 30000); it(`/api/routes`, async () => { const response = await request.get('/api/routes'); expect(response.status).toBe(200); diff --git a/test/utils/rand-user-agent.js b/test/utils/rand-user-agent.js index 8efbc71c3d..eefab0b625 100644 --- a/test/utils/rand-user-agent.js +++ b/test/utils/rand-user-agent.js @@ -26,15 +26,15 @@ describe('rand-user-agent', () => { }); it('should match ua configurated', async () => { - const response1 = await got('https://www.whatsmyua.info/api/v1/ua'); - expect(response1.data[0].ua.rawUa).toBe(config.ua); + const response1 = await got('https://httpbingo.org/user-agent'); + expect(response1.data['user-agent']).toBe(config.ua); - const response2 = await got('https://www.whatsmyua.info/api/v1/ua', { + const response2 = await got('https://httpbingo.org/user-agent', { headers: { 'user-agent': mobileUa, }, }); - expect(response2.data[0].ua.rawUa).toBe(mobileUa); - expect(response2.data[0].ua.rawUa).not.toBe(config.ua); + expect(response2.data['user-agent']).toBe(mobileUa); + expect(response2.data['user-agent']).not.toBe(config.ua); }); });