mirror of
https://github.com/spacebarchat/server.git
synced 2024-11-22 18:32:29 +01:00
added unittest setup + ping route test
This commit is contained in:
parent
95d7084887
commit
cebc19bee2
3
cdn/.gitignore
vendored
3
cdn/.gitignore
vendored
@ -3,4 +3,5 @@ node_modules/
|
||||
.DS_Store
|
||||
.env
|
||||
dist/
|
||||
files/
|
||||
files/
|
||||
coverage/
|
14
cdn/CONTRIBUTE.md
Normal file
14
cdn/CONTRIBUTE.md
Normal file
@ -0,0 +1,14 @@
|
||||
# CONTRIBUTE
|
||||
|
||||
### Setup:
|
||||
|
||||
```
|
||||
npm i
|
||||
npm start
|
||||
```
|
||||
|
||||
### Run tests:
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
1
cdn/jest/setup.js
Normal file
1
cdn/jest/setup.js
Normal file
@ -0,0 +1 @@
|
||||
jest.spyOn(global.console, "log").mockImplementation(() => jest.fn());
|
6618
cdn/package-lock.json
generated
6618
cdn/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -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"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -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
22
cdn/tests/start.test.js
Normal 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");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user