Skip to content

Commit 0744902

Browse files
committed
add another vending test
1 parent 8b30e05 commit 0744902

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

tests/unit/vending.test.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
1-
import { expect, test } from "vitest";
1+
import { afterAll, describe, expect, test } from "vitest";
22
import init from "../../src/api/index.js";
3+
import { beforeEach } from "node:test";
4+
import supertest from "supertest";
35

46
const app = await init();
5-
test("Test getting events", async () => {
6-
const response = await app.inject({
7-
method: "GET",
8-
url: "/api/v1/vending/items",
7+
describe("Vending routes tests", async () => {
8+
test("Test getting vending items", async () => {
9+
const response = await app.inject({
10+
method: "GET",
11+
url: "/api/v1/vending/items",
12+
});
13+
expect(response.statusCode).toBe(200);
14+
});
15+
test("Test adding vending items", async () => {
16+
const response = await supertest(app.server)
17+
.post("/api/v1/vending/items")
18+
.send({
19+
name: "Test",
20+
imageUrl: "https://google.com",
21+
price: 1,
22+
});
23+
expect(response.statusCode).toBe(200);
24+
expect(response.body).toStrictEqual({ status: "Not implemented." });
25+
});
26+
afterAll(async () => {
27+
await app.close();
28+
});
29+
beforeEach(() => {
30+
(app as any).nodeCache.flushAll();
931
});
10-
expect(response.statusCode).toBe(200);
1132
});

0 commit comments

Comments
 (0)