1
0
Fork 0
mirror of https://github.com/kou029w/_.git synced 2025-01-31 06:18:07 +00:00
_/kita/test/index.test.ts

40 lines
917 B
TypeScript
Raw Permalink Normal View History

2024-04-20 01:21:32 +09:00
import fastify from 'fastify';
import assert from 'node:assert';
import test, { describe } from 'node:test';
import backendPlugin from '../src/plugin';
describe('Creates route', () => {
test('GET /', async () => {
await using app = fastify();
app.register(backendPlugin);
const response = await app.inject({
method: 'GET',
url: '/'
});
assert.strictEqual(response.statusCode, 200);
assert.deepStrictEqual(response.json(), {
name: 'World',
message: 'Hello World!'
});
});
test('GET /?name=Kita', async () => {
await using app = fastify();
app.register(backendPlugin);
const response = await app.inject({
method: 'GET',
url: '/',
query: { name: 'Kita' }
});
assert.strictEqual(response.statusCode, 200);
assert.deepStrictEqual(response.json(), {
name: 'Kita',
message: 'Hello Kita!'
});
});
});