summary refs log tree commit diff
path: root/api/tests
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-18 11:56:06 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-09-18 11:56:06 +0200
commitaae7e8d7770f6d5f7d46c2263880c6c4e7ef6788 (patch)
treed1625d8ddd80fef1499d6beab4e26566cf8ee55d /api/tests
parent:sparkles: jest automatic tests (diff)
downloadserver-aae7e8d7770f6d5f7d46c2263880c6c4e7ef6788.tar.xz
:sparkles: route middleware test option
Diffstat (limited to 'api/tests')
-rw-r--r--api/tests/routes.test.ts11
1 files changed, 4 insertions, 7 deletions
diff --git a/api/tests/routes.test.ts b/api/tests/routes.test.ts
index e913e0dc..4cb7e6bc 100644
--- a/api/tests/routes.test.ts
+++ b/api/tests/routes.test.ts
@@ -3,13 +3,13 @@
 
 import getRouteDescriptions from "../jest/getRouteDescriptions";
 import supertest, { Response } from "supertest";
-import path from "path";
+import { join } from "path";
 import fs from "fs";
 import Ajv from "ajv";
 import addFormats from "ajv-formats";
 const request = supertest("http://localhost:3001/api");
 
-const SchemaPath = path.join(__dirname, "..", "assets", "responses.json");
+const SchemaPath = join(__dirname, "..", "assets", "responses.json");
 const schemas = JSON.parse(fs.readFileSync(SchemaPath, { encoding: "utf8" }));
 export const ajv = new Ajv({
 	allErrors: true,
@@ -27,13 +27,10 @@ describe("Automatic unit tests with route description middleware", () => {
 
 	routes.forEach((route, pathAndMethod) => {
 		const [path, method] = pathAndMethod.split("|");
+
 		test(path, (done) => {
 			if (!route.example) {
-				console.log(`Route ${path} is missing the example property`);
-				return done();
-			}
-			if (!route.response) {
-				console.log(`Route ${path} is missing the response property`);
+				console.log(`${(route as any).file}\nrouter.${method} is missing the test property`);
 				return done();
 			}
 			const urlPath = path || route.example?.path;