Merge branch 'master' of https://github.com/fosscord/fosscord-api
This commit is contained in:
commit
f056885fb0
@ -5,7 +5,7 @@
|
||||
"main": "dist/Server.js",
|
||||
"types": "dist/Server.d.ts",
|
||||
"scripts": {
|
||||
"test": "npm run build && jest --coverage --verbose ./tests",
|
||||
"test": "npm run build && jest --coverage --verbose --forceExit ./tests",
|
||||
"test:watch": "jest --watch",
|
||||
"start": "npm run build && node dist/start",
|
||||
"build": "npx tsc -b .",
|
||||
@ -90,9 +90,9 @@
|
||||
},
|
||||
"jest": {
|
||||
"setupFiles": [
|
||||
"<rootDir>/jest/setup.js",
|
||||
"<rootDir>/scripts/setup_test.js"
|
||||
"<rootDir>/jest/setup.js"
|
||||
],
|
||||
"globalSetup": "<rootDir>/scripts/globalSetup.js",
|
||||
"verbose": true
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,13 @@
|
||||
const fs = require("fs");
|
||||
const { FosscordServer } = require("../dist/Server");
|
||||
const Server = new FosscordServer({ port: 3001 });
|
||||
(async () => {
|
||||
global.server = Server;
|
||||
module.exports = async () => {
|
||||
try {
|
||||
fs.unlinkSync(`${__dirname}/database.db`);
|
||||
fs.unlinkSync(`${__dirname}/../database.db`);
|
||||
} catch {}
|
||||
return await Server.start();
|
||||
})();
|
||||
};
|
||||
|
||||
// afterAll(async () => {
|
||||
// return await Server.stop();
|
||||
33
api/tests/routes/auth/login.test.js
Normal file
33
api/tests/routes/auth/login.test.js
Normal 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);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,2 +0,0 @@
|
||||
const supertest = require("supertest");
|
||||
const request = supertest("http://localhost:1870");
|
||||
@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
BIN
cdn/package-lock.json
generated
BIN
cdn/package-lock.json
generated
Binary file not shown.
@ -21,7 +21,7 @@ export function initDatabase() {
|
||||
//
|
||||
entities: Object.values(Models).filter((x) => x.constructor.name !== "Object"),
|
||||
synchronize: true,
|
||||
logging: true,
|
||||
logging: false,
|
||||
cache: {
|
||||
duration: 1000 * 3, // cache all find queries for 3 seconds
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user