feat: Convert factories files to JS
This commit is contained in:
25
packages/backend/test/factories/connection.js
Normal file
25
packages/backend/test/factories/connection.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import appConfig from '../../src/config/app';
|
||||
import { AES } from 'crypto-js';
|
||||
|
||||
export const createConnection = async (params = {}) => {
|
||||
params.key = params?.key || 'deepl';
|
||||
|
||||
const formattedData = params.formattedData || {
|
||||
screenName: 'Test - DeepL Connection',
|
||||
authenticationKey: 'test key',
|
||||
};
|
||||
|
||||
delete params.formattedData;
|
||||
|
||||
params.data = AES.encrypt(
|
||||
JSON.stringify(formattedData),
|
||||
appConfig.encryptionKey
|
||||
).toString();
|
||||
|
||||
const [connection] = await global.knex
|
||||
.table('connections')
|
||||
.insert(params)
|
||||
.returning('*');
|
||||
|
||||
return connection;
|
||||
};
|
Reference in New Issue
Block a user