refactor: Rename fixtures as factories to differentiate dynamic data

This commit is contained in:
Faruk AYDIN
2023-10-23 10:30:27 +02:00
parent 31b1b9457b
commit 655deb12c8
12 changed files with 16 additions and 16 deletions

View 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;