1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/lib/middleware/no-authentication.test.js
2020-10-02 16:32:05 +02:00

30 lines
697 B
JavaScript

'use strict';
const test = require('ava');
const supertest = require('supertest');
const express = require('express');
const noAuthentication = require('./no-authentication');
test('should add dummy user object to all requests', t => {
t.plan(1);
const app = express();
noAuthentication('', app);
app.get('/api/admin/test', (req, 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 => {
t.true(res.body.username === 'unknown');
});
});