Preview: record-json.factory.ts
Size: 1.17 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/adminjs/src/frontend/components/spec/record-json.factory.ts
import { factory } from 'factory-girl'
import './action-json.factory.js'
import { ActionJSON, RecordJSON } from '../../interfaces/index.js'
factory.define<RecordJSON>('RecordJSON', Object, {
params: {
param1: 'value1',
'nested.param': 'value2',
},
populated: {},
baseError: null,
errors: {},
id: factory.sequence('JSONRecord.id', (n) => `someId${n}`),
title: factory.sequence('JSONRecord.id', (n) => `someTitle${n}`),
recordActions: [],
bulkActions: [],
})
factory.extend('RecordJSON', 'RecordJSON.total', {
// params set for properties from ResourceJSON.total factory's properties
params: {
name: 'John',
surname: 'Doe',
gender: 'MALE',
},
}, {
afterBuild: async (model) => {
const showAction = await factory.build<ActionJSON>('ActionJSON', {
name: 'show', actionType: 'record',
})
const editAction = await factory.build<ActionJSON>('ActionJSON', {
name: 'edit', actionType: 'record',
})
const deleteAction = await factory.build<ActionJSON>('ActionJSON', {
name: 'delete', actionType: 'record',
})
return {
...model,
recordActions: [showAction, editAction, deleteAction],
}
},
})
Directory Contents
Dirs: 0 × Files: 8