UNPKG

1.67 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3var chai_1 = require("chai");
4var _1 = require(".");
5describe('express', function () {
6 describe('routes', function () {
7 it('list routes', function () {
8 var router = _1.express.router();
9 router.get('/foo', function (req, res) { return true; });
10 router.get('/foo/:id', function (req, res) { return true; });
11 router.put('/foo/:id', function (req, res) { return true; });
12 router.post('/foo/:id', function (req, res) { return true; });
13 router.delete('/foo/:id', function (req, res) { return true; });
14 router.patch('/foo/:id', function (req, res) { return true; });
15 var res = _1.express.routes(router);
16 chai_1.expect(res.length).to.eql(2);
17 chai_1.expect(res[0].path).to.eql('/foo');
18 chai_1.expect(res[0].methods).to.eql(['GET']);
19 chai_1.expect(res[1].path).to.eql('/foo/:id');
20 chai_1.expect(res[1].methods).to.eql(['GET', 'PUT', 'POST', 'DELETE', 'PATCH']);
21 });
22 it('has no routes', function () {
23 var router = _1.express.router();
24 var res = _1.express.routes(router);
25 chai_1.expect(res).to.eql([]);
26 });
27 it('has no methods on a route', function () {
28 var router = _1.express.router();
29 router.get('/foo');
30 var res = _1.express.routes(router);
31 chai_1.expect(res.length).to.eql(1);
32 chai_1.expect(res[0]).to.eql({ path: '/foo', methods: [] });
33 });
34 });
35});
36//# sourceMappingURL=express.test.js.map
\No newline at end of file