Skip to content

Commit

Permalink
feat: add unit tests for Fastify API
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Sep 24, 2023
1 parent 49d83a4 commit 06ccf42
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/api.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { fastify } from 'fastify';
import { describe, expect, test } from '@jest/globals';

const app = fastify();

describe('Fastify API', () => {
test('GET /api', async () => {
const response = await app.inject({
method: 'GET',
url: '/api'
});

expect(response.statusCode).toBe(200);
});

test('GET /api/hello', async () => {
const response = await app.inject({
method: 'GET',
url: '/api/hello'
});

expect(response.statusCode).toBe(200);
});

test('GET /api/ping', async () => {
const response = await app.inject({
method: 'GET',
url: '/api/ping'
});

expect(response.statusCode).toBe(200);
expect(response.json()).toEqual({ pong: 'it worked!' });
});
});

0 comments on commit 06ccf42

Please sign in to comment.