mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: convert files to typescript
This commit is contained in:
parent
d3b9bcb7be
commit
436f295dc5
@ -1,7 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const express = require('express');
|
||||
const { createTestConfig } = require('../test/config/test-config');
|
||||
import express from 'express';
|
||||
import { createTestConfig } from '../test/config/test-config';
|
||||
|
||||
jest.mock(
|
||||
'./routes',
|
@ -1,12 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const parseDbUrl = require('parse-database-url');
|
||||
|
||||
module.exports = {
|
||||
getDb: () => {
|
||||
const url =
|
||||
process.env.TEST_DATABASE_URL ||
|
||||
'postgres://unleash_user:passord@localhost:5432/unleash_test';
|
||||
return parseDbUrl(url);
|
||||
},
|
||||
};
|
8
src/test/e2e/helpers/database-config.ts
Normal file
8
src/test/e2e/helpers/database-config.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import parseDbUrl from 'parse-database-url';
|
||||
|
||||
export const getDbConfig = (): object => {
|
||||
const url =
|
||||
process.env.TEST_DATABASE_URL ||
|
||||
'postgres://unleash_user:passord@localhost:5432/unleash_test';
|
||||
return parseDbUrl(url);
|
||||
};
|
@ -2,7 +2,7 @@ import { EventEmitter } from 'events';
|
||||
import { migrateDb } from '../../../migrator';
|
||||
import { createStores } from '../../../lib/db';
|
||||
import { createDb } from '../../../lib/db/db-pool';
|
||||
import dbConfig from './database-config';
|
||||
import { getDbConfig } from './database-config';
|
||||
import { createTestConfig } from '../../config/test-config';
|
||||
import dbState from './database.json';
|
||||
import { LogProvider } from '../../../lib/logger';
|
||||
@ -77,12 +77,12 @@ export interface ITestDb {
|
||||
}
|
||||
|
||||
export default async function init(
|
||||
databaseSchema: String = 'test',
|
||||
databaseSchema: string = 'test',
|
||||
getLogger: LogProvider = noLoggerProvider,
|
||||
): Promise<ITestDb> {
|
||||
const config = createTestConfig({
|
||||
db: {
|
||||
...dbConfig.getDb(),
|
||||
...getDbConfig(),
|
||||
pool: { min: 2, max: 8 },
|
||||
schema: databaseSchema,
|
||||
ssl: false,
|
||||
|
@ -1,7 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = () => {
|
||||
const _perms = ['ADMIN'];
|
||||
const adminUser = (): { hook: (app: any) => void } => {
|
||||
return {
|
||||
hook(app) {
|
||||
app.use((req, res, next) => {
|
||||
@ -9,10 +6,12 @@ module.exports = () => {
|
||||
isAPI: true,
|
||||
id: 1,
|
||||
email: 'unknown',
|
||||
permissions: _perms,
|
||||
permissions: ['ADMIN'],
|
||||
};
|
||||
next();
|
||||
});
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
export default adminUser;
|
Loading…
Reference in New Issue
Block a user