summary refs log tree commit diff
path: root/tests/routes
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2022-08-13 02:00:50 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-13 22:00:55 +0200
commit5e86d7ab9c5200d794c3adb2b422d20a2aefd2ce (patch)
tree0a4b23ee96862077b21dea20cf71205709e15f7c /tests/routes
parenttry to update build script (diff)
downloadserver-ts-5e86d7ab9c5200d794c3adb2b422d20a2aefd2ce.tar.xz
restructure to single project
Diffstat (limited to 'tests/routes')
-rw-r--r--tests/routes/auth/login.test.js33
-rw-r--r--tests/routes/auth/register.test.js27
-rw-r--r--tests/routes/ping.test.js12
3 files changed, 72 insertions, 0 deletions
diff --git a/tests/routes/auth/login.test.js b/tests/routes/auth/login.test.js
new file mode 100644

index 00000000..d4b52444 --- /dev/null +++ b/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/tests/routes/auth/register.test.js b/tests/routes/auth/register.test.js new file mode 100644
index 00000000..5d7b4eaa --- /dev/null +++ b/tests/routes/auth/register.test.js
@@ -0,0 +1,27 @@ +const supertest = require("supertest"); +const request = supertest("http://localhost:3001"); + +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 () => { + const response = await request.post("/api/auth/register").send({ + fingerprint: "805826570869932034.wR8vi8lGlFBJerErO9LG5NViJFw", + email: "qo8etzvaf@gmail.com", + username: "qp39gr98", + password: "wtp9gep9gw", + invite: null, + consent: true, + date_of_birth: "2000-04-04", + gift_code_sku_id: null, + captcha_key: null + }); + + expect(response.statusCode).toBe(200); + }); + }); +}); diff --git a/tests/routes/ping.test.js b/tests/routes/ping.test.js new file mode 100644
index 00000000..6fa4b160 --- /dev/null +++ b/tests/routes/ping.test.js
@@ -0,0 +1,12 @@ +const supertest = require("supertest"); +const request = supertest("http://localhost:3001"); + +describe("/ping", () => { + describe("GET", () => { + test("should return 200 and pong", async () => { + let response = await request.get("/api/ping"); + expect(response.text).toBe("pong"); + expect(response.statusCode).toBe(200); + }); + }); +});