UNPKG

unleash-server

Version:

Unleash is an enterprise ready feature flag service. It provides different strategies for handling feature flags.

52 lines 1.63 kB
import { setupAppWithCustomAuth, } from '../../helpers/test-helper.js'; import dbInit from '../../helpers/database-init.js'; import getLogger from '../../../fixtures/no-logger.js'; let stores; let db; let app; beforeAll(async () => { db = await dbInit('splash_api_serial', getLogger); stores = db.stores; const email = 'custom-user@mail.com'; const preHook = (application, _config, { userService }) => { application.use('/api/admin/', async (req, _res, next) => { // @ts-expect-error req.user = await userService.loginUserWithoutPassword(email, true); next(); }); }; app = await setupAppWithCustomAuth(stores, preHook, { experimental: { flags: { strictSchemaValidation: true, }, }, }); }); afterAll(async () => { await app.destroy(); await db.destroy(); }); test('it updates splash for user', async () => { expect.assertions(1); return app.request .post('/api/admin/splash/environment') .set('Content-Type', 'application/json') .expect('Content-Type', /json/) .expect(200) .expect((res) => { expect(res.body.seen).toBe(true); }); }); test('it retrieves splash for user', async () => { expect.assertions(1); return app.request .get('/api/admin/user') .set('Content-Type', 'application/json') .expect('Content-Type', /json/) .expect(200) .expect((res) => { expect(res.body.splash).toStrictEqual({ environment: true }); }); }); //# sourceMappingURL=splash.e2e.test.js.map