removed deprecated logger-related functions, default to console if no logger provided
[squeep-api-dingus] / test / lib / router.js
index d63917087d1490021d5441564669008c60f1676c..8a9d1e26f8e1e502cc5b0e164bb78d56ec457785 100644 (file)
@@ -5,7 +5,7 @@
 const assert = require('assert');
 const sinon = require('sinon'); // eslint-disable-line node/no-unpublished-require
 const Router = require('../../lib/router');
-const PathParameter = require('../../lib/router/path-parameter')
+const PathParameter = require('../../lib/router/path-parameter');
 const { DingusError } = require('../../lib/errors');
 
 const noExpectedException = 'did not get expected exception';
@@ -46,6 +46,13 @@ describe('Router', function () {
       const r = router._pathToRoutePath(p);
       assert.deepStrictEqual(r, expected);
     });
+    it('defines a path with escaped parameter', function () {
+      const p = '/a/\\:b/c';
+      const expected = ['', 'a', ':b', 'c'];
+      expected[Router.kPathMethods] = {};
+      const r = router._pathToRoutePath(p);
+      assert.deepStrictEqual(r, expected);
+    });
   }); // _pathToRoutePath
 
   describe('_pathCompareExact', function () {
@@ -291,6 +298,7 @@ describe('Router', function () {
 
       const { handler } = router.lookup(method, path, ctx);
       assert.strictEqual(handler, stubHandler);
+      assert.strictEqual(ctx.matchedPath, urlPath);
     });
     it('does not find handler with trailing slash', function () {
       router.ignoreTrailingSlash = false;