|
|
@@ -35,251 +35,336 @@ describe('Route', function () {
|
|
|
})();
|
|
|
});
|
|
|
|
|
|
- it('requires the option "method" to be a non-empty String', function () {
|
|
|
- const throwable = v => () =>
|
|
|
- new Route({
|
|
|
- method: v,
|
|
|
+ describe('the "method" option', function () {
|
|
|
+ it('requires the "method" option to be a non-empty String', function () {
|
|
|
+ const throwable = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: v,
|
|
|
+ path: '/',
|
|
|
+ handler: () => undefined,
|
|
|
+ });
|
|
|
+ const error = v =>
|
|
|
+ format(
|
|
|
+ 'The option "method" of the Route should be ' +
|
|
|
+ 'a non-empty String, but %s was given.',
|
|
|
+ v,
|
|
|
+ );
|
|
|
+ expect(throwable('')).to.throw(error('""'));
|
|
|
+ expect(throwable(10)).to.throw(error('10'));
|
|
|
+ expect(throwable(0)).to.throw(error('0'));
|
|
|
+ expect(throwable(true)).to.throw(error('true'));
|
|
|
+ expect(throwable(false)).to.throw(error('false'));
|
|
|
+ expect(throwable(null)).to.throw(error('null'));
|
|
|
+ expect(throwable({})).to.throw(error('Object'));
|
|
|
+ expect(throwable([])).to.throw(error('Array'));
|
|
|
+ expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
+ expect(throwable(() => undefined)).to.throw(error('Function'));
|
|
|
+ throwable(HttpMethod.GET)();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('sets the "method" option in upper case to the "method" property', function () {
|
|
|
+ const route = new Route({
|
|
|
+ method: 'post',
|
|
|
path: '/',
|
|
|
handler: () => undefined,
|
|
|
});
|
|
|
- const error = v =>
|
|
|
- format(
|
|
|
- 'The option "method" of the Route should be ' +
|
|
|
- 'a non-empty String, but %s was given.',
|
|
|
- v,
|
|
|
- );
|
|
|
- expect(throwable('')).to.throw(error('""'));
|
|
|
- expect(throwable(10)).to.throw(error('10'));
|
|
|
- expect(throwable(0)).to.throw(error('0'));
|
|
|
- expect(throwable(true)).to.throw(error('true'));
|
|
|
- expect(throwable(false)).to.throw(error('false'));
|
|
|
- expect(throwable(null)).to.throw(error('null'));
|
|
|
- expect(throwable({})).to.throw(error('Object'));
|
|
|
- expect(throwable([])).to.throw(error('Array'));
|
|
|
- expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
- expect(throwable(() => undefined)).to.throw(error('Function'));
|
|
|
- throwable(HttpMethod.GET)();
|
|
|
+ expect(route.method).to.be.eq('POST');
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
- it('requires the option "path" to be a non-empty String', function () {
|
|
|
- const throwable = v => () =>
|
|
|
- new Route({
|
|
|
+ describe('the "path" option', function () {
|
|
|
+ it('requires the "path" option to be a non-empty String', function () {
|
|
|
+ const throwable = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: v,
|
|
|
+ handler: () => undefined,
|
|
|
+ });
|
|
|
+ const error = v =>
|
|
|
+ format(
|
|
|
+ 'The option "path" of the Route should be ' +
|
|
|
+ 'a String, but %s was given.',
|
|
|
+ v,
|
|
|
+ );
|
|
|
+ expect(throwable(10)).to.throw(error('10'));
|
|
|
+ expect(throwable(0)).to.throw(error('0'));
|
|
|
+ expect(throwable(true)).to.throw(error('true'));
|
|
|
+ expect(throwable(false)).to.throw(error('false'));
|
|
|
+ expect(throwable(null)).to.throw(error('null'));
|
|
|
+ expect(throwable({})).to.throw(error('Object'));
|
|
|
+ expect(throwable([])).to.throw(error('Array'));
|
|
|
+ expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
+ expect(throwable(() => undefined)).to.throw(error('Function'));
|
|
|
+ throwable('str')();
|
|
|
+ throwable('')();
|
|
|
+ });
|
|
|
+
|
|
|
+ it('sets the "path" option to the "path" property', function () {
|
|
|
+ const value = '/myPath';
|
|
|
+ const route = new Route({
|
|
|
method: HttpMethod.GET,
|
|
|
- path: v,
|
|
|
+ path: value,
|
|
|
handler: () => undefined,
|
|
|
});
|
|
|
- const error = v =>
|
|
|
- format(
|
|
|
- 'The option "path" of the Route should be ' +
|
|
|
- 'a String, but %s was given.',
|
|
|
- v,
|
|
|
- );
|
|
|
- expect(throwable(10)).to.throw(error('10'));
|
|
|
- expect(throwable(0)).to.throw(error('0'));
|
|
|
- expect(throwable(true)).to.throw(error('true'));
|
|
|
- expect(throwable(false)).to.throw(error('false'));
|
|
|
- expect(throwable(null)).to.throw(error('null'));
|
|
|
- expect(throwable({})).to.throw(error('Object'));
|
|
|
- expect(throwable([])).to.throw(error('Array'));
|
|
|
- expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
- expect(throwable(() => undefined)).to.throw(error('Function'));
|
|
|
- throwable('str')();
|
|
|
- throwable('')();
|
|
|
+ expect(route.path).to.be.eq(value);
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
- it('requires the option "handler" to be a non-empty String', function () {
|
|
|
- const throwable = v => () =>
|
|
|
- new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
- path: '/',
|
|
|
- handler: v,
|
|
|
- });
|
|
|
- const error = v =>
|
|
|
- format(
|
|
|
- 'The option "handler" of the Route should be ' +
|
|
|
- 'a Function, but %s was given.',
|
|
|
- v,
|
|
|
- );
|
|
|
- expect(throwable('str')).to.throw(error('"str"'));
|
|
|
- expect(throwable('')).to.throw(error('""'));
|
|
|
- expect(throwable(10)).to.throw(error('10'));
|
|
|
- expect(throwable(0)).to.throw(error('0'));
|
|
|
- expect(throwable(true)).to.throw(error('true'));
|
|
|
- expect(throwable(false)).to.throw(error('false'));
|
|
|
- expect(throwable(null)).to.throw(error('null'));
|
|
|
- expect(throwable({})).to.throw(error('Object'));
|
|
|
- expect(throwable([])).to.throw(error('Array'));
|
|
|
- expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
- throwable(() => undefined)();
|
|
|
- });
|
|
|
+ describe('the "meta" option', function () {
|
|
|
+ it('requires the "meta" option to be a plain Object', function () {
|
|
|
+ const throwable = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: 'path',
|
|
|
+ handler: () => undefined,
|
|
|
+ meta: v,
|
|
|
+ });
|
|
|
+ const error = v =>
|
|
|
+ format(
|
|
|
+ 'The option "meta" of the Route should be ' +
|
|
|
+ 'a plain Object, but %s was given.',
|
|
|
+ v,
|
|
|
+ );
|
|
|
+ expect(throwable(10)).to.throw(error('10'));
|
|
|
+ expect(throwable(0)).to.throw(error('0'));
|
|
|
+ expect(throwable(true)).to.throw(error('true'));
|
|
|
+ expect(throwable(false)).to.throw(error('false'));
|
|
|
+ expect(throwable([])).to.throw(error('Array'));
|
|
|
+ expect(throwable(() => undefined)).to.throw(error('Function'));
|
|
|
+ throwable({foo: 'bar'})();
|
|
|
+ throwable({})();
|
|
|
+ throwable(null)();
|
|
|
+ throwable(undefined)();
|
|
|
+ });
|
|
|
|
|
|
- it('requires the option "preHandler" to be a Function or an Array of Function', function () {
|
|
|
- const throwable1 = v => () =>
|
|
|
- new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
+ it('sets the "meta" option to the "meta" property as a deep copy', function () {
|
|
|
+ const metaData = {foo: {bar: {baz: 'qux'}}};
|
|
|
+ const route = new Route({
|
|
|
+ method: 'post',
|
|
|
path: '/',
|
|
|
- preHandler: v,
|
|
|
handler: () => undefined,
|
|
|
+ meta: metaData,
|
|
|
});
|
|
|
- const error = v =>
|
|
|
- format(
|
|
|
- 'The hook "preHandler" should be a Function, but %s was given.',
|
|
|
- v,
|
|
|
- );
|
|
|
- expect(throwable1('str')).to.throw(error('"str"'));
|
|
|
- expect(throwable1('')).to.throw(error('""'));
|
|
|
- expect(throwable1(10)).to.throw(error('10'));
|
|
|
- expect(throwable1(0)).to.throw(error('0'));
|
|
|
- expect(throwable1(true)).to.throw(error('true'));
|
|
|
- expect(throwable1(false)).to.throw(error('false'));
|
|
|
- expect(throwable1({})).to.throw(error('Object'));
|
|
|
- throwable1([])();
|
|
|
- throwable1(() => undefined)();
|
|
|
- throwable1(null)();
|
|
|
- throwable1(undefined)();
|
|
|
- const throwable2 = v => () =>
|
|
|
- new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
+ expect(route.meta).to.be.not.eq(metaData);
|
|
|
+ expect(route.meta).to.be.eql(metaData);
|
|
|
+ expect(route.meta.foo).to.be.not.eq(metaData.foo);
|
|
|
+ expect(route.meta.foo).to.be.eql(metaData.foo);
|
|
|
+ expect(route.meta.foo.bar).to.be.not.eq(metaData.foo.bar);
|
|
|
+ expect(route.meta.foo.bar).to.be.eql(metaData.foo.bar);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('sets an empty object to the "meta" property if the "meta" option is not provided', function () {
|
|
|
+ const route = new Route({
|
|
|
+ method: 'post',
|
|
|
path: '/',
|
|
|
- preHandler: [v],
|
|
|
handler: () => undefined,
|
|
|
});
|
|
|
- expect(throwable2('str')).to.throw(error('"str"'));
|
|
|
- expect(throwable2('')).to.throw(error('""'));
|
|
|
- expect(throwable2(10)).to.throw(error('10'));
|
|
|
- expect(throwable2(0)).to.throw(error('0'));
|
|
|
- expect(throwable2(true)).to.throw(error('true'));
|
|
|
- expect(throwable2(false)).to.throw(error('false'));
|
|
|
- expect(throwable2({})).to.throw(error('Object'));
|
|
|
- expect(throwable2(null)).to.throw(error('null'));
|
|
|
- expect(throwable2([])).to.throw(error('Array'));
|
|
|
- expect(throwable2(undefined)).to.throw(error('undefined'));
|
|
|
- throwable2(() => undefined)();
|
|
|
- });
|
|
|
+ expect(route.meta).to.be.eql({});
|
|
|
+ });
|
|
|
|
|
|
- it('requires the option "postHandler" to be a Function or an Array of Function', function () {
|
|
|
- const throwable1 = v => () =>
|
|
|
- new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
+ it('sets an empty object to the "meta" property if the "meta" option is undefined', function () {
|
|
|
+ const route = new Route({
|
|
|
+ method: 'post',
|
|
|
path: '/',
|
|
|
handler: () => undefined,
|
|
|
- postHandler: v,
|
|
|
+ meta: undefined,
|
|
|
});
|
|
|
- const error = v =>
|
|
|
- format(
|
|
|
- 'The hook "postHandler" should be a Function, but %s was given.',
|
|
|
- v,
|
|
|
- );
|
|
|
- expect(throwable1('str')).to.throw(error('"str"'));
|
|
|
- expect(throwable1('')).to.throw(error('""'));
|
|
|
- expect(throwable1(10)).to.throw(error('10'));
|
|
|
- expect(throwable1(0)).to.throw(error('0'));
|
|
|
- expect(throwable1(true)).to.throw(error('true'));
|
|
|
- expect(throwable1(false)).to.throw(error('false'));
|
|
|
- expect(throwable1({})).to.throw(error('Object'));
|
|
|
- throwable1([])();
|
|
|
- throwable1(() => undefined)();
|
|
|
- throwable1(null)();
|
|
|
- throwable1(undefined)();
|
|
|
- const throwable2 = v => () =>
|
|
|
- new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
+ expect(route.meta).to.be.eql({});
|
|
|
+ });
|
|
|
+
|
|
|
+ it('sets an empty object to the "meta" property if the "meta" option is null', function () {
|
|
|
+ const route = new Route({
|
|
|
+ method: 'post',
|
|
|
path: '/',
|
|
|
handler: () => undefined,
|
|
|
- postHandler: [v],
|
|
|
+ meta: null,
|
|
|
});
|
|
|
- expect(throwable2('str')).to.throw(error('"str"'));
|
|
|
- expect(throwable2('')).to.throw(error('""'));
|
|
|
- expect(throwable2(10)).to.throw(error('10'));
|
|
|
- expect(throwable2(0)).to.throw(error('0'));
|
|
|
- expect(throwable2(true)).to.throw(error('true'));
|
|
|
- expect(throwable2(false)).to.throw(error('false'));
|
|
|
- expect(throwable2({})).to.throw(error('Object'));
|
|
|
- expect(throwable2(null)).to.throw(error('null'));
|
|
|
- expect(throwable2([])).to.throw(error('Array'));
|
|
|
- expect(throwable2(undefined)).to.throw(error('undefined'));
|
|
|
- throwable2(() => undefined)();
|
|
|
+ expect(route.meta).to.be.eql({});
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
- it('sets the option "method" in upper case to the "method" property', function () {
|
|
|
- const route = new Route({
|
|
|
- method: 'post',
|
|
|
- path: '/',
|
|
|
- handler: () => undefined,
|
|
|
+ describe('the "handler" option', function () {
|
|
|
+ it('requires the "handler" option to be a non-empty String', function () {
|
|
|
+ const throwable = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ handler: v,
|
|
|
+ });
|
|
|
+ const error = v =>
|
|
|
+ format(
|
|
|
+ 'The option "handler" of the Route should be ' +
|
|
|
+ 'a Function, but %s was given.',
|
|
|
+ v,
|
|
|
+ );
|
|
|
+ expect(throwable('str')).to.throw(error('"str"'));
|
|
|
+ expect(throwable('')).to.throw(error('""'));
|
|
|
+ expect(throwable(10)).to.throw(error('10'));
|
|
|
+ expect(throwable(0)).to.throw(error('0'));
|
|
|
+ expect(throwable(true)).to.throw(error('true'));
|
|
|
+ expect(throwable(false)).to.throw(error('false'));
|
|
|
+ expect(throwable(null)).to.throw(error('null'));
|
|
|
+ expect(throwable({})).to.throw(error('Object'));
|
|
|
+ expect(throwable([])).to.throw(error('Array'));
|
|
|
+ expect(throwable(undefined)).to.throw(error('undefined'));
|
|
|
+ throwable(() => undefined)();
|
|
|
});
|
|
|
- expect(route.method).to.be.eq('POST');
|
|
|
- });
|
|
|
|
|
|
- it('sets the option "path" to the "path" property', function () {
|
|
|
- const value = '/myPath';
|
|
|
- const route = new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
- path: value,
|
|
|
- handler: () => undefined,
|
|
|
+ it('sets the "handler" option to the "handler" property', function () {
|
|
|
+ const value = () => undefined;
|
|
|
+ const route = new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ handler: value,
|
|
|
+ });
|
|
|
+ expect(route.handler).to.be.eq(value);
|
|
|
});
|
|
|
- expect(route.path).to.be.eq(value);
|
|
|
});
|
|
|
|
|
|
- it('sets the option "handler" to the "handler" property', function () {
|
|
|
- const value = () => undefined;
|
|
|
- const route = new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
- path: '/',
|
|
|
- handler: value,
|
|
|
+ describe('the "preHandler" option', function () {
|
|
|
+ it('requires the "preHandler" option to be a Function or an Array of Function', function () {
|
|
|
+ const throwable1 = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ preHandler: v,
|
|
|
+ handler: () => undefined,
|
|
|
+ });
|
|
|
+ const error = v =>
|
|
|
+ format(
|
|
|
+ 'The hook "preHandler" should be a Function, but %s was given.',
|
|
|
+ v,
|
|
|
+ );
|
|
|
+ expect(throwable1('str')).to.throw(error('"str"'));
|
|
|
+ expect(throwable1('')).to.throw(error('""'));
|
|
|
+ expect(throwable1(10)).to.throw(error('10'));
|
|
|
+ expect(throwable1(0)).to.throw(error('0'));
|
|
|
+ expect(throwable1(true)).to.throw(error('true'));
|
|
|
+ expect(throwable1(false)).to.throw(error('false'));
|
|
|
+ expect(throwable1({})).to.throw(error('Object'));
|
|
|
+ throwable1([])();
|
|
|
+ throwable1(() => undefined)();
|
|
|
+ throwable1(null)();
|
|
|
+ throwable1(undefined)();
|
|
|
+ const throwable2 = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ preHandler: [v],
|
|
|
+ handler: () => undefined,
|
|
|
+ });
|
|
|
+ expect(throwable2('str')).to.throw(error('"str"'));
|
|
|
+ expect(throwable2('')).to.throw(error('""'));
|
|
|
+ expect(throwable2(10)).to.throw(error('10'));
|
|
|
+ expect(throwable2(0)).to.throw(error('0'));
|
|
|
+ expect(throwable2(true)).to.throw(error('true'));
|
|
|
+ expect(throwable2(false)).to.throw(error('false'));
|
|
|
+ expect(throwable2({})).to.throw(error('Object'));
|
|
|
+ expect(throwable2(null)).to.throw(error('null'));
|
|
|
+ expect(throwable2([])).to.throw(error('Array'));
|
|
|
+ expect(throwable2(undefined)).to.throw(error('undefined'));
|
|
|
+ throwable2(() => undefined)();
|
|
|
});
|
|
|
- expect(route.handler).to.be.eq(value);
|
|
|
- });
|
|
|
|
|
|
- it('adds a Function to "preHandler" hooks', function () {
|
|
|
- const value = () => undefined;
|
|
|
- const route = new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
- path: '/',
|
|
|
- preHandler: value,
|
|
|
- handler: () => undefined,
|
|
|
+ it('adds a Function to "preHandler" hooks', function () {
|
|
|
+ const value = () => undefined;
|
|
|
+ const route = new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ preHandler: value,
|
|
|
+ handler: () => undefined,
|
|
|
+ });
|
|
|
+ expect(route.hookRegistry.hasHook(RouterHookType.PRE_HANDLER, value)).to
|
|
|
+ .be.true;
|
|
|
});
|
|
|
- expect(route.hookRegistry.hasHook(RouterHookType.PRE_HANDLER, value)).to
|
|
|
- .be.true;
|
|
|
- });
|
|
|
|
|
|
- it('adds Function items of an Array to "preHandler" hooks', function () {
|
|
|
- const value = [() => undefined, () => undefined];
|
|
|
- const route = new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
- path: '/',
|
|
|
- preHandler: value,
|
|
|
- handler: () => undefined,
|
|
|
+ it('adds a Function Array to "preHandler" hooks', function () {
|
|
|
+ const value = [() => undefined, () => undefined];
|
|
|
+ const route = new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ preHandler: value,
|
|
|
+ handler: () => undefined,
|
|
|
+ });
|
|
|
+ expect(route.hookRegistry.hasHook(RouterHookType.PRE_HANDLER, value[0]))
|
|
|
+ .to.be.true;
|
|
|
+ expect(route.hookRegistry.hasHook(RouterHookType.PRE_HANDLER, value[1]))
|
|
|
+ .to.be.true;
|
|
|
});
|
|
|
- expect(route.hookRegistry.hasHook(RouterHookType.PRE_HANDLER, value[0]))
|
|
|
- .to.be.true;
|
|
|
- expect(route.hookRegistry.hasHook(RouterHookType.PRE_HANDLER, value[1]))
|
|
|
- .to.be.true;
|
|
|
});
|
|
|
|
|
|
- it('adds a Function to "postHandler" hooks', function () {
|
|
|
- const value = () => undefined;
|
|
|
- const route = new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
- path: '/',
|
|
|
- handler: () => undefined,
|
|
|
- postHandler: value,
|
|
|
+ describe('the "postHandler" option', function () {
|
|
|
+ it('requires the "postHandler" option to be a Function or an Array of Function', function () {
|
|
|
+ const throwable1 = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ handler: () => undefined,
|
|
|
+ postHandler: v,
|
|
|
+ });
|
|
|
+ const error = v =>
|
|
|
+ format(
|
|
|
+ 'The hook "postHandler" should be a Function, but %s was given.',
|
|
|
+ v,
|
|
|
+ );
|
|
|
+ expect(throwable1('str')).to.throw(error('"str"'));
|
|
|
+ expect(throwable1('')).to.throw(error('""'));
|
|
|
+ expect(throwable1(10)).to.throw(error('10'));
|
|
|
+ expect(throwable1(0)).to.throw(error('0'));
|
|
|
+ expect(throwable1(true)).to.throw(error('true'));
|
|
|
+ expect(throwable1(false)).to.throw(error('false'));
|
|
|
+ expect(throwable1({})).to.throw(error('Object'));
|
|
|
+ throwable1([])();
|
|
|
+ throwable1(() => undefined)();
|
|
|
+ throwable1(null)();
|
|
|
+ throwable1(undefined)();
|
|
|
+ const throwable2 = v => () =>
|
|
|
+ new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ handler: () => undefined,
|
|
|
+ postHandler: [v],
|
|
|
+ });
|
|
|
+ expect(throwable2('str')).to.throw(error('"str"'));
|
|
|
+ expect(throwable2('')).to.throw(error('""'));
|
|
|
+ expect(throwable2(10)).to.throw(error('10'));
|
|
|
+ expect(throwable2(0)).to.throw(error('0'));
|
|
|
+ expect(throwable2(true)).to.throw(error('true'));
|
|
|
+ expect(throwable2(false)).to.throw(error('false'));
|
|
|
+ expect(throwable2({})).to.throw(error('Object'));
|
|
|
+ expect(throwable2(null)).to.throw(error('null'));
|
|
|
+ expect(throwable2([])).to.throw(error('Array'));
|
|
|
+ expect(throwable2(undefined)).to.throw(error('undefined'));
|
|
|
+ throwable2(() => undefined)();
|
|
|
});
|
|
|
- expect(route.hookRegistry.hasHook(RouterHookType.POST_HANDLER, value)).to
|
|
|
- .be.true;
|
|
|
- });
|
|
|
|
|
|
- it('adds Function items of an Array to "postHandler" hooks', function () {
|
|
|
- const value = [() => undefined, () => undefined];
|
|
|
- const route = new Route({
|
|
|
- method: HttpMethod.GET,
|
|
|
- path: '/',
|
|
|
- handler: () => undefined,
|
|
|
- postHandler: value,
|
|
|
+ it('adds a Function to "postHandler" hooks', function () {
|
|
|
+ const value = () => undefined;
|
|
|
+ const route = new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ handler: () => undefined,
|
|
|
+ postHandler: value,
|
|
|
+ });
|
|
|
+ expect(route.hookRegistry.hasHook(RouterHookType.POST_HANDLER, value))
|
|
|
+ .to.be.true;
|
|
|
+ });
|
|
|
+
|
|
|
+ it('adds a Function Array to "postHandler" hooks', function () {
|
|
|
+ const value = [() => undefined, () => undefined];
|
|
|
+ const route = new Route({
|
|
|
+ method: HttpMethod.GET,
|
|
|
+ path: '/',
|
|
|
+ handler: () => undefined,
|
|
|
+ postHandler: value,
|
|
|
+ });
|
|
|
+ expect(
|
|
|
+ route.hookRegistry.hasHook(RouterHookType.POST_HANDLER, value[0]),
|
|
|
+ ).to.be.true;
|
|
|
+ expect(
|
|
|
+ route.hookRegistry.hasHook(RouterHookType.POST_HANDLER, value[1]),
|
|
|
+ ).to.be.true;
|
|
|
});
|
|
|
- expect(route.hookRegistry.hasHook(RouterHookType.POST_HANDLER, value[0]))
|
|
|
- .to.be.true;
|
|
|
- expect(route.hookRegistry.hasHook(RouterHookType.POST_HANDLER, value[1]))
|
|
|
- .to.be.true;
|
|
|
});
|
|
|
});
|
|
|
|