Files
medusa-store/integration-tests/factories/simple-batch-job-factory.ts
Adrien de Peretti 4d326fbbdf chore: Move factories and helpers to a better place (#4551)
* chore: Move factories and helpers to a better place

* align factory product variant

* fix factory cart

* add simple store fac

* fix tests

* fix tests

* fix

* fix cart seeder
2023-07-20 13:16:04 +02:00

31 lines
817 B
TypeScript

import { DataSource } from "typeorm"
import { BatchJob, BatchJobStatus } from "@medusajs/medusa"
export type BatchJobFactoryData = {
id?: string
type?: string
status?: BatchJobStatus
created_by?: string
context?: Record<string, unknown>
awaiting_confirmation_at?: Date | string
completed_at?: Date | string
}
export const simpleBatchJobFactory = async (
dataSource: DataSource,
data: BatchJobFactoryData = {}
): Promise<BatchJob> => {
const manager = dataSource.manager
const job = manager.create<BatchJob>(BatchJob, {
id: data.id,
status: data.status ?? BatchJobStatus.CREATED,
completed_at: data.completed_at ?? null,
type: data.type ?? "test-job",
created_by: data.created_by ?? null,
context: data.context ?? {},
})
return await manager.save<BatchJob>(job)
}