feat(api): s/jest/vitest/g (#61863)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>
This commit is contained in:
Mrugesh Mohapatra
2025-08-25 22:57:56 +05:30
committed by GitHub
parent fed489f092
commit 45c098d506
58 changed files with 1974 additions and 907 deletions

View File

@@ -1,3 +1,4 @@
import { describe, test, expect, beforeEach, afterEach } from 'vitest';
import Fastify, { FastifyInstance } from 'fastify';
import jwt from 'jsonwebtoken';
@@ -30,7 +31,7 @@ describe('auth', () => {
// We won't need to keep doubly signing the cookie when we migrate the
// authentication, but for the MVP we have to be able to read the cookies
// set by the api-server. So, double signing:
it('should doubly sign the cookie', async () => {
test('should doubly sign the cookie', async () => {
const token = createAccessToken('test-id');
fastify.get('/test', async (req, reply) => {
reply.setAccessTokenCookie(token);
@@ -68,7 +69,7 @@ describe('auth', () => {
fastify.addHook('onRequest', fastify.authorize);
});
it('should deny if the access token is missing', async () => {
test('should deny if the access token is missing', async () => {
expect.assertions(4);
fastify.addHook('onRequest', (req, _reply, done) => {
@@ -89,7 +90,7 @@ describe('auth', () => {
expect(res.statusCode).toEqual(200);
});
it('should deny if the access token is not signed', async () => {
test('should deny if the access token is not signed', async () => {
expect.assertions(4);
fastify.addHook('onRequest', (req, _reply, done) => {
@@ -117,7 +118,7 @@ describe('auth', () => {
expect(res.statusCode).toEqual(200);
});
it('should deny if the access token is invalid', async () => {
test('should deny if the access token is invalid', async () => {
expect.assertions(4);
fastify.addHook('onRequest', (req, _reply, done) => {
@@ -146,7 +147,7 @@ describe('auth', () => {
expect(res.statusCode).toEqual(200);
});
it('should deny if the access token has expired', async () => {
test('should deny if the access token has expired', async () => {
expect.assertions(4);
fastify.addHook('onRequest', (req, _reply, done) => {
@@ -175,7 +176,7 @@ describe('auth', () => {
expect(res.statusCode).toEqual(200);
});
it('should deny if the user is not found', async () => {
test('should deny if the user is not found', async () => {
expect.assertions(4);
fastify.addHook('onRequest', (req, _reply, done) => {
@@ -207,7 +208,7 @@ describe('auth', () => {
expect(res.statusCode).toEqual(200);
});
it('should populate the request with the user if the token is valid', async () => {
test('should populate the request with the user if the token is valid', async () => {
const fakeUser = { id: '123', username: 'test-user' };
// @ts-expect-error prisma isn't defined, since we're not building the
// full application here.
@@ -235,7 +236,7 @@ describe('auth', () => {
});
describe('onRequest Hook', () => {
it('should update the jwt_access_token to httpOnly and secure', async () => {
test('should update the jwt_access_token to httpOnly and secure', async () => {
const rawValue = 'should-not-change';
fastify.get('/test', (req, reply) => {
reply.send({ ok: true });
@@ -260,7 +261,7 @@ describe('auth', () => {
expect(res.statusCode).toBe(200);
});
it('should do nothing if there is no jwt_access_token', async () => {
test('should do nothing if there is no jwt_access_token', async () => {
fastify.get('/test', (req, reply) => {
reply.send({ ok: true });
});