Compare commits
2 Commits
88cdce819b
...
98086640e5
Author | SHA1 | Date |
---|---|---|
Suguivy | 98086640e5 | |
Sugui | d749743e56 |
13
package.json
13
package.json
|
@ -3,13 +3,20 @@
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"bun-types": "latest"
|
"@types/jest": "^29.5.11",
|
||||||
|
"@types/supertest": "^6.0.1",
|
||||||
|
"bun-types": "latest",
|
||||||
|
"jest": "^29.7.0",
|
||||||
|
"supertest": "^6.3.3",
|
||||||
|
"ts-jest": "^29.1.1"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
},"scripts": {
|
},
|
||||||
|
"scripts": {
|
||||||
"start": "bun run src/index.ts",
|
"start": "bun run src/index.ts",
|
||||||
"dev": "bun --hot run src/index.ts"
|
"dev": "bun --hot run src/index.ts",
|
||||||
|
"test": "bun test"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
|
|
|
@ -2,7 +2,7 @@ import express from "express";
|
||||||
import mongoose from "mongoose";
|
import mongoose from "mongoose";
|
||||||
import ImageModel from "./ImageModel";
|
import ImageModel from "./ImageModel";
|
||||||
|
|
||||||
const app = express();
|
export const app = express();
|
||||||
|
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { describe, expect, it } from "bun:test";
|
||||||
|
import request from "supertest";
|
||||||
|
import { app } from "../src";
|
||||||
|
|
||||||
|
describe("GET /images works properly", () => {
|
||||||
|
it("should be an array", async () => {
|
||||||
|
const res = await request(app).get("/images");
|
||||||
|
expect(Array.isArray(res.body)).toBeTrue();
|
||||||
|
expect(res.statusCode).toBe(200);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("POST /images works properly", () => {
|
||||||
|
it("should return 201 or 409", async () => {
|
||||||
|
const res = await request(app).post("/images").send({
|
||||||
|
url: "https://test.url.com/123",
|
||||||
|
status: "available",
|
||||||
|
tags: ["2girls", "touhou"]
|
||||||
|
});
|
||||||
|
expect(res.status).toSatisfy(status => [201, 409].includes(status));
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue