X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Flib%2Frouter.js;h=488d5ceec03ceb5f006230999ce335cf8e2d111c;hb=8e981f499075ec8bbd9229076d4448e6212ca87a;hp=8a9d1e26f8e1e502cc5b0e164bb78d56ec457785;hpb=914e78e62c740792ed7f6de319360ea4aa60c67e;p=squeep-api-dingus diff --git a/test/lib/router.js b/test/lib/router.js index 8a9d1e2..488d5ce 100644 --- a/test/lib/router.js +++ b/test/lib/router.js @@ -6,7 +6,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 { DingusError } = require('../../lib/errors'); +const { DingusError, RouterNoPathError, RouterNoMethodError } = require('../../lib/errors'); const noExpectedException = 'did not get expected exception'; @@ -260,7 +260,7 @@ describe('Router', function () { router.on('FLARP', urlPath, stubHandler); assert.fail('expected an exception'); } catch (e) { - assert.strictEqual(e.name, 'DingusError'); + assert(e instanceof DingusError); assert.strictEqual(e.message, 'invalid method \'FLARP\''); } }); @@ -311,8 +311,7 @@ describe('Router', function () { router.lookup(method, path, ctx); assert.fail(noExpectedException); } catch (e) { - assert(e instanceof DingusError); - assert.strictEqual(e.message, 'NoPath'); + assert(e instanceof RouterNoPathError); } }); it('finds handler', function () { @@ -353,8 +352,7 @@ describe('Router', function () { router.lookup(method, path, ctx); assert.fail(noExpectedException); } catch (e) { - assert(e instanceof DingusError); - assert.strictEqual(e.message, 'NoMethod'); + assert(e instanceof RouterNoMethodError); } }); it('does not lookup non-existent path', async function () { @@ -365,8 +363,7 @@ describe('Router', function () { router.lookup(method, path, ctx); assert.fail(noExpectedException); } catch (e) { - assert(e instanceof DingusError); - assert.strictEqual(e.message, 'NoPath'); + assert(e instanceof RouterNoPathError); } });