9b2fb1ed828f68f26ac9462f06f826a10d243f00
4 const assert
= require('assert');
5 const PathParameter
= require('../../../lib/router/path-parameter');
7 const noExpectedException
= 'did not receive expected exception';
8 describe('PathParameter', function () {
9 beforeEach(function () {
10 PathParameter
._flush();
12 it('requires a parameter', function () {
15 assert
.fail(noExpectedException
);
17 assert(e
instanceof RangeError
, noExpectedException
);
20 it('requires parameter be a string', function () {
22 new PathParameter({});
23 assert
.fail(noExpectedException
);
25 assert(e
instanceof RangeError
, noExpectedException
);
28 it('creates a parameter object', function () {
29 const p
= new PathParameter('foo');
30 assert(p
instanceof PathParameter
);
31 assert
.strictEqual(p
.parameter
, 'foo');
33 it('duplicate parameters are the same object', function () {
34 const p1
= new PathParameter('foo');
35 const p2
= new PathParameter('foo');
36 assert
.strictEqual(p1
, p2
);
38 it('shows itself', function () {
39 const p
= new PathParameter('foo');
40 assert(p
.toString().includes('foo'));
42 it('parameters are immutable', function () {
43 const p
= new PathParameter('foo');
45 p
[PathParameter
.kPathParameter
] = 'bar';
46 assert
.fail(noExpectedException
);
48 assert(e
instanceof TypeError
, noExpectedException
);