1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-24 20:06:55 +01:00
unleash.unleash/src/lib/middleware/no-authentication.test.ts
Gastón Fournier abe160eb7d
feat: Unleash v7 ESM migration (#9877)
We're migrating to ESM, which will allow us to import the latest
versions of our dependencies.

Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
2025-05-14 09:47:12 +02:00

25 lines
725 B
TypeScript

import type { IAuthRequest } from '../routes/unleash-types.js';
import supertest from 'supertest';
import express from 'express';
import noAuthentication from './no-authentication.js';
test('should add dummy user object to all requests', () => {
expect.assertions(1);
const app = express();
noAuthentication('', app);
app.get('/api/admin/test', (req: IAuthRequest<any, any, any, any>, res) => {
const user = { ...req.user };
return res.status(200).json(user).end();
});
const request = supertest(app);
return request
.get('/api/admin/test')
.expect(200)
.expect((res) => {
expect(res.body.username === 'unknown').toBe(true);
});
});