1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-10 20:52:42 +01:00

added /login unittest

This commit is contained in:
xnacly 2021-09-01 22:14:06 +02:00
parent 3905c51b35
commit 66d3d5a6c6
3 changed files with 36 additions and 3 deletions

View File

@ -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);
});
});
});

View File

@ -1,2 +0,0 @@
const supertest = require("supertest");
const request = supertest("http://localhost:1870");

View File

@ -1,10 +1,11 @@
const supertest = require("supertest"); const supertest = require("supertest");
const request = supertest("http://localhost:3001"); const request = supertest("http://localhost:3001");
describe("/api/register", () => { describe("/api/auth/register", () => {
describe("POST", () => { describe("POST", () => {
test("without body", async () => { test("without body", async () => {
const response = await request.post("/api/auth/register").send({}); const response = await request.post("/api/auth/register").send({});
expect(response.statusCode).toBe(400); expect(response.statusCode).toBe(400);
}); });
test("with body", async () => { test("with body", async () => {
@ -19,6 +20,7 @@ describe("/api/register", () => {
gift_code_sku_id: null, gift_code_sku_id: null,
captcha_key: null captcha_key: null
}); });
expect(response.statusCode).toBe(200); expect(response.statusCode).toBe(200);
}); });
}); });