test: Implement config fixture
This commit is contained in:
23
packages/backend/test/fixtures/config.ts
vendored
Normal file
23
packages/backend/test/fixtures/config.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { IJSONObject } from '@automatisch/types';
|
||||||
|
import { faker } from '@faker-js/faker';
|
||||||
|
|
||||||
|
type ConfigParams = {
|
||||||
|
key?: string;
|
||||||
|
value?: IJSONObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
const createConfig = async (params: ConfigParams = {}) => {
|
||||||
|
const configData = {
|
||||||
|
key: params?.key || faker.lorem.word(),
|
||||||
|
value: params?.value || { data: 'sampleConfig' },
|
||||||
|
};
|
||||||
|
|
||||||
|
const [config] = await global.knex
|
||||||
|
.table('config')
|
||||||
|
.insert(configData)
|
||||||
|
.returning('*');
|
||||||
|
|
||||||
|
return config;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default createConfig;
|
Reference in New Issue
Block a user