1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-23 02:42:28 +01:00

added unittest setup + ping route test

This commit is contained in:
xnacly 2021-08-18 13:57:23 +02:00
parent 95d7084887
commit cebc19bee2
7 changed files with 6656 additions and 13 deletions

1
cdn/.gitignore vendored
View File

@ -4,3 +4,4 @@ node_modules/
.env
dist/
files/
coverage/

14
cdn/CONTRIBUTE.md Normal file
View File

@ -0,0 +1,14 @@
# CONTRIBUTE
### Setup:
```
npm i
npm start
```
### Run tests:
```
npm test
```

1
cdn/jest/setup.js Normal file
View File

@ -0,0 +1 @@
jest.spyOn(global.console, "log").mockImplementation(() => jest.fn());

6618
cdn/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "npm run build && jest --coverage ./tests",
"build": "npx tsc -b .",
"start": "npm run build && node dist/start.js"
},
@ -48,12 +48,19 @@
"file-type": "^16.5.0",
"fs-extra": "^10.0.0",
"image-size": "^1.0.0",
"jest": "^27.0.6",
"lambert-db": "^1.2.3",
"lambert-server": "^1.2.8",
"missing-native-js-functions": "^1.2.10",
"multer": "^1.4.2",
"node-fetch": "^2.6.1",
"supertest": "^6.1.6",
"typescript": "^4.1.2",
"uuid": "^8.3.2"
},
"jest": {
"setupFilesAfterEnv": [
"<rootDir>/jest/setup.js"
]
}
}

View File

@ -25,3 +25,5 @@ server
console.log("[Server] started on :" + server.options.port);
})
.catch((e) => console.error("[Server] Error starting: ", e));
module.exports = server;

22
cdn/tests/start.test.js Normal file
View File

@ -0,0 +1,22 @@
const { CDNServer } = require("../dist/Server");
const { db } = require("@fosscord/util");
const supertest = require("supertest");
const request = supertest("http://localhost:3003");
const server = new CDNServer({ port: Number(process.env.PORT) || 3003 });
beforeAll(async () => {
await server.start();
db.close();
return server;
});
afterAll(() => {
return server.stop();
});
describe("GET /ping", () => {
test("should return pong", async () => {
const response = await request.get("/ping");
expect(response.text).toBe("pong");
});
});