summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
authorxnacly <matteogropp@protonmail.com>2021-09-01 22:14:06 +0200
committerxnacly <matteogropp@protonmail.com>2021-09-01 22:14:06 +0200
commit66d3d5a6c61c9a982eaf3c16843d8af2ecc5b5f8 (patch)
treedb42ec1a70d2ec1a7891d6cfb6c0c283826bacaf /api
parentsee parent (diff)
downloadserver-66d3d5a6c61c9a982eaf3c16843d8af2ecc5b5f8.tar.xz
added /login unittest
Diffstat (limited to 'api')
-rw-r--r--api/tests/routes/auth/login.test.js33
-rw-r--r--api/tests/routes/auth/login.test.js.disabled2
-rw-r--r--api/tests/routes/auth/register.test.js4
3 files changed, 36 insertions, 3 deletions
diff --git a/api/tests/routes/auth/login.test.js b/api/tests/routes/auth/login.test.js
new file mode 100644
index 00000000..d4b52444
--- /dev/null
+++ b/api/tests/routes/auth/login.test.js
@@ -0,0 +1,33 @@
+const supertest = require("supertest");
+const request = supertest("http://localhost:3001");
+
+describe("/api/auth/login", () => {
+	describe("POST", () => {
+		test("without body", async () => {
+			const response = await request.post("/api/auth/login").send({});
+			expect(response.statusCode).toBe(400);
+		});
+		test("with body", async () => {
+			const user = {
+				login: "fortnitefortnite@gmail.com",
+				password: "verysecurepassword"
+			};
+
+			await request.post("/api/auth/register").send({
+				fingerprint: "805826570869932034.wR8vi8lGlFBJerErO9LG5NViJFw",
+				email: user.login,
+				username: user.login.split("@")[0],
+				password: user.password,
+				invite: null,
+				consent: true,
+				date_of_birth: "2000-04-04",
+				gift_code_sku_id: null,
+				captcha_key: null
+			});
+
+			const response = await request.post("/api/auth/login").send(user);
+
+			expect(response.statusCode).toBe(200);
+		});
+	});
+});
diff --git a/api/tests/routes/auth/login.test.js.disabled b/api/tests/routes/auth/login.test.js.disabled
deleted file mode 100644
index f677cebd..00000000
--- a/api/tests/routes/auth/login.test.js.disabled
+++ /dev/null
@@ -1,2 +0,0 @@
-const supertest = require("supertest");
-const request = supertest("http://localhost:1870");
diff --git a/api/tests/routes/auth/register.test.js b/api/tests/routes/auth/register.test.js
index f42f004a..5d7b4eaa 100644
--- a/api/tests/routes/auth/register.test.js
+++ b/api/tests/routes/auth/register.test.js
@@ -1,10 +1,11 @@
 const supertest = require("supertest");
 const request = supertest("http://localhost:3001");
 
-describe("/api/register", () => {
+describe("/api/auth/register", () => {
 	describe("POST", () => {
 		test("without body", async () => {
 			const response = await request.post("/api/auth/register").send({});
+
 			expect(response.statusCode).toBe(400);
 		});
 		test("with body", async () => {
@@ -19,6 +20,7 @@ describe("/api/register", () => {
 				gift_code_sku_id: null,
 				captcha_key: null
 			});
+
 			expect(response.statusCode).toBe(200);
 		});
 	});