mirror of
https://github.com/kou029w/_.git
synced 2025-01-31 06:18:07 +00:00
39 lines
917 B
TypeScript
39 lines
917 B
TypeScript
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!'
|
|
});
|
|
});
|
|
});
|