diff --git a/test/api.test.ts b/test/api.test.ts index d92629c..29d5e3c 100644 --- a/test/api.test.ts +++ b/test/api.test.ts @@ -1,26 +1,38 @@ -import { afterAll, beforeAll, describe, test, expect } from 'bun:test'; import fastify from 'fastify'; +import assert from 'assert'; -import { server } from '../server'; +// TODO: Import server when it's needed +// import { server } from '../server'; -const app = fastify(); +// Test for GET /api +app.inject({ + method: 'GET', + url: '/api' +}, (err, response) => { + if (err) { console.error(err); assert.fail(err); } + assert.strictEqual(response.statusCode, 200); + assert.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8'); +}); -describe('API', () => { - beforeAll(async () => { - await server.ready(); - }); +// Test for GET /api/hello +app.inject({ + method: 'GET', + url: '/api/hello' +}, (err, response) => { + if (err) { console.error(err); assert.fail(err); } + assert.strictEqual(response.statusCode, 200); + assert.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8'); +}); - afterAll(async () => { - await server.close(); - }); - - test('should return 200', async () => { - const response = await app.inject({ - method: 'GET', - url: '/api', - }); - - expect(response.statusCode).toBe(200); - }); -}) +// Test for GET /api/ping +server.inject({ + method: 'GET', + url: '/api/ping' +}, (err, response) => { + if (err) { console.error(err); assert.fail(err); } + assert.strictEqual(response.statusCode, 200); + assert.strictEqual(response.headers['content-type'], 'application/json; charset=utf-8'); +}); +// The server should not be closed yet, as per user's comment +// server.close().catch((err) => console.error(err));