mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-12 15:03:20 -05:00
27 lines
947 B
TypeScript
27 lines
947 B
TypeScript
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
import request from 'supertest';
|
|
|
|
describe('GET /', () => {
|
|
test('have a 200 response', async () => {
|
|
const res = await request(fastifyTestInstance?.server).get('/');
|
|
expect(res?.statusCode).toBe(200);
|
|
});
|
|
|
|
test('return { "hello": "world"}', async () => {
|
|
const res = await request(fastifyTestInstance?.server).get('/');
|
|
expect(res?.body).toEqual({ hello: 'world' });
|
|
});
|
|
|
|
test('should have OWASP recommended headers', async () => {
|
|
const res = await request(fastifyTestInstance?.server).get('/');
|
|
// We also set Strict-Transport-Security, but only in production.
|
|
expect(res?.headers).toMatchObject({
|
|
'cache-control': 'no-store',
|
|
'content-security-policy': "frame-ancestors 'none'",
|
|
'content-type': 'application/json; charset=utf-8',
|
|
'x-content-type-options': 'nosniff',
|
|
'x-frame-options': 'DENY'
|
|
});
|
|
});
|
|
});
|