added unittests for ping and attachments
This commit is contained in:
parent
8f498e6934
commit
de077cced9
@ -24,21 +24,21 @@ const server = new CDNServer({ port: Number(process.env.PORT) || 3003 });
|
|||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
await server.start();
|
await server.start();
|
||||||
db.close();
|
|
||||||
return server;
|
return server;
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(() => {
|
afterAll(() => {
|
||||||
|
db.close();
|
||||||
return server.stop();
|
return server.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
let attachment_url = "";
|
|
||||||
|
|
||||||
describe("/ping", () => {
|
describe("/ping", () => {
|
||||||
describe("GET", () => {
|
describe("GET", () => {
|
||||||
test("route should return pong", async () => {
|
describe("without signature specified", () => {
|
||||||
const response = await request.get("/ping").set({ signature: Config.get().security.requestSignature });
|
test("route should respond with 200", async () => {
|
||||||
expect(response.text).toBe("pong");
|
let response = await request.get("/ping");
|
||||||
|
expect(response.text).toBe("pong");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -51,7 +51,7 @@ describe("/attachments", () => {
|
|||||||
expect(response.statusCode).toBe(400);
|
expect(response.statusCode).toBe(400);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("without file specified and with signature specified", () => {
|
describe("with signature specified, without file specified", () => {
|
||||||
test("route should respond with 400", async () => {
|
test("route should respond with 400", async () => {
|
||||||
const response = await request
|
const response = await request
|
||||||
.post("/attachments/123456789")
|
.post("/attachments/123456789")
|
||||||
@ -59,8 +59,8 @@ describe("/attachments", () => {
|
|||||||
expect(response.statusCode).toBe(400);
|
expect(response.statusCode).toBe(400);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
describe("with file specified and with signature specified", () => {
|
describe("with signature specified, with file specified ", () => {
|
||||||
test("route should respond with Content-type application/json and 200 and res.body.url", async () => {
|
test("route should respond with Content-type: application/json, 200 and res.body.url", async () => {
|
||||||
const response = await request
|
const response = await request
|
||||||
.post("/attachments/123456789")
|
.post("/attachments/123456789")
|
||||||
.set({ signature: Config.get().security.requestSignature })
|
.set({ signature: Config.get().security.requestSignature })
|
||||||
@ -72,19 +72,19 @@ describe("/attachments", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// describe("GET", () => {
|
describe("GET", () => {
|
||||||
// describe("getting uploaded image by url returned by POST /attachments", () => {
|
describe("getting uploaded image by url returned by POST /attachments", () => {
|
||||||
// test("route should respond with 200", async () => {
|
test("route should respond with 200", async () => {
|
||||||
// let response = await request
|
let response = await request
|
||||||
// .post("/attachments/123456789")
|
.post("/attachments/123456789")
|
||||||
// .set({ signature: Config.get().security.requestSignature })
|
.set({ signature: Config.get().security.requestSignature })
|
||||||
// .attach("file", __dirname + "/antman.jpg");
|
.attach("file", __dirname + "/antman.jpg");
|
||||||
// console.warn(response.body.url.replace("http://localhost:3003", ""));
|
request.get(response.body.url.replace("http://localhost:3003", "")).then((x) => {
|
||||||
// response = request.get(response.body.url.replace("http://localhost:3003", ""));
|
expect(x.statusCode).toBe(400);
|
||||||
// expect(response.statusCode).toBe(400);
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
describe("DELETE", () => {
|
describe("DELETE", () => {
|
||||||
describe("without signature specified", () => {});
|
describe("without signature specified", () => {});
|
||||||
});
|
});
|
Loading…
x
Reference in New Issue
Block a user