|
1 | | -import { expect, test } from "vitest"; |
| 1 | +import { afterAll, describe, expect, test } from "vitest"; |
2 | 2 | import init from "../../src/api/index.js"; |
| 3 | +import { beforeEach } from "node:test"; |
| 4 | +import supertest from "supertest"; |
3 | 5 |
|
4 | 6 | 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(); |
9 | 31 | }); |
10 | | - expect(response.statusCode).toBe(200); |
11 | 32 | }); |
0 commit comments