tests(middleware-joi): fixed failing tests caused by types error
MODIFY
packages/middleware-joi/test/unit/body.spec.ts
packages/middleware-joi/test/unit/body.spec.ts
@@ -23,7 +23,7 @@ describe('Joi middleware - Body', () => {
};
const http$ = bodyParser$(req$, res, {});
- const valid$ = validator$(schema)(http$);
+ const valid$ = validator$(schema)(http$, undefined as unknown as HttpResponse, {});
valid$.subscribe(
() => {
@@ -59,7 +59,7 @@ describe('Joi middleware - Body', () => {
};
const http$ = bodyParser$(req$, res, {});
- const valid$ = validator$(schema)(http$);
+ const valid$ = validator$(schema)(http$, undefined as unknown as HttpResponse, {});
valid$.subscribe(
() => {
@@ -95,7 +95,7 @@ describe('Joi middleware - Body', () => {
};
const http$ = bodyParser$(req$, res, {});
- const valid$ = validator$(schema, { allowUnknown: true })(http$);
+ const valid$ = validator$(schema, { allowUnknown: true })(http$, undefined as unknown as HttpResponse, {});
valid$.subscribe(data => {
expect(data).toBeTruthy();

MODIFY
packages/middleware-joi/test/unit/header.spec.ts
packages/middleware-joi/test/unit/header.spec.ts
import { validator$, Joi } from '../../src';
import { of } from 'rxjs';
-import { HttpRequest } from '@marblejs/core';
+import { HttpRequest, HttpResponse } from '@marblejs/core';
const MockReq = require('mock-req');
describe('Joi middleware - Header', () => {
@@ -20,7 +20,7 @@ describe('Joi middleware - Header', () => {
.required()
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(
() => {
@@ -51,7 +51,7 @@ describe('Joi middleware - Header', () => {
start: Joi.date()
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(
() => {
@@ -83,7 +83,7 @@ describe('Joi middleware - Header', () => {
start: Joi.number().integer()
})
};
- const http$ = validator$(schema, { stripUnknown: true })(req$);
+ const http$ = validator$(schema, { stripUnknown: true })(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(data => {
expect(data).toBeTruthy();
@@ -114,7 +114,7 @@ describe('Joi middleware - Header', () => {
.min(1)
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(data => {
expect(data).toBeTruthy();

MODIFY
packages/middleware-joi/test/unit/params.spec.ts
packages/middleware-joi/test/unit/params.spec.ts
import { validator$, Joi } from '../../src';
import { of } from 'rxjs';
-import { HttpRequest, RouteParameters } from '@marblejs/core';
+import { HttpRequest, RouteParameters, HttpResponse } from '@marblejs/core';
const reqMatched = (
url: string,
@@ -26,7 +26,7 @@ describe('Joi middleware - Params', () => {
.required()
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(
() => {
@@ -50,7 +50,7 @@ describe('Joi middleware - Params', () => {
id: Joi.string().token()
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(
() => {
@@ -78,7 +78,7 @@ describe('Joi middleware - Params', () => {
.default('181782881DB38D84')
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(data => {
expect(data).toBeDefined();

MODIFY
packages/middleware-joi/test/unit/query.spec.ts
packages/middleware-joi/test/unit/query.spec.ts
import { validator$, Joi } from '../../src';
import { of } from 'rxjs';
-import { HttpRequest, RouteParameters, QueryParameters } from '@marblejs/core';
+import { HttpRequest, RouteParameters, QueryParameters, HttpResponse } from '@marblejs/core';
const reqMatched = (
url: string,
@@ -21,7 +21,7 @@ describe('Joi middleware - Query', () => {
.required()
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(
() => {
@@ -45,7 +45,7 @@ describe('Joi middleware - Query', () => {
id: Joi.string().token()
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(
() => {
@@ -71,7 +71,7 @@ describe('Joi middleware - Query', () => {
id: Joi.string().token()
})
};
- const http$ = validator$(schema)(req$);
+ const http$ = validator$(schema)(req$, undefined as unknown as HttpResponse, {});
http$.subscribe(data => {
expect(data).toBeDefined();

MODIFY
packages/middleware-joi/test/unit/schema.spec.ts
packages/middleware-joi/test/unit/schema.spec.ts
-import { HttpRequest } from '@marblejs/core';
+import { HttpRequest, HttpResponse } from '@marblejs/core';
import { Observable } from 'rxjs';
import { validator$ } from '../../src';
describe('Joi middleware - Schema', () => {
it('should throws an error if using an invalid schema', done => {
const schema = { headers: 'foo' };
- const http$ = validator$(schema)(undefined as unknown as Observable<HttpRequest>);
+ const http$ = validator$(schema)(
+ undefined as unknown as Observable<HttpRequest>,
+ undefined as unknown as HttpResponse,
+ {},
+ );
http$.subscribe(
() => {
fail('Exceptions should be thrown');
@@ -19,7 +23,11 @@ describe('Joi middleware - Schema', () => {
});
it('should throws an error if using an empty schema', done => {
- const http$ = validator$({})(undefined as unknown as Observable<HttpRequest>);
+ const http$ = validator$({})(
+ undefined as unknown as Observable<HttpRequest>,
+ undefined as unknown as HttpResponse,
+ {},
+ );
http$.subscribe(
() => {
fail('Exceptions should be thrown');

tests(middleware-joi): fixed failing tests caused by types error