import { expect } from 'chai'; import { express } from '.'; describe('express', () => { describe('routes', () => { it('list routes', () => { const router = express.router(); router.get('/foo', (req, res) => true); router.get('/foo/:id', (req, res) => true); router.put('/foo/:id', (req, res) => true); router.post('/foo/:id', (req, res) => true); router.delete('/foo/:id', (req, res) => true); router.patch('/foo/:id', (req, res) => true); const res = express.routes(router); expect(res.length).to.eql(2); expect(res[0].path).to.eql('/foo'); expect(res[0].methods).to.eql(['GET']); expect(res[1].path).to.eql('/foo/:id'); expect(res[1].methods).to.eql(['GET', 'PUT', 'POST', 'DELETE', 'PATCH']); }); it('has no routes', () => { const router = express.router(); const res = express.routes(router); expect(res).to.eql([]); }); it('has no methods on a route', () => { const router = express.router(); router.get('/foo'); const res = express.routes(router); expect(res.length).to.eql(1); expect(res[0]).to.eql({ path: '/foo', methods: [] }); }); }); });