Files
medusa-store/integration-tests/factories/simple-customer-group-factory.ts.txt
Riqwan Thamir 0573bb924a chore: Remove typeORM (#9005)
* chore: rename js files to txt

* chore: rename ts files to txt

* chore: delete environment helpers

* chore: convert global setup & teardown to txt

* chore: rename helper js/ts files to txt

* chore: rename seeder js/ts files to txt

* chore: remove typeorm

* chore: reintroduce used helpers
2024-09-05 15:45:30 +02:00

32 lines
722 B
Plaintext

import { CustomerGroup } from "@medusajs/medusa"
import faker from "faker"
import { DataSource } from "typeorm"
export type CustomerGroupFactoryData = {
id?: string
name?: string
}
export const simpleCustomerGroupFactory = async (
dataSource: DataSource,
data: CustomerGroupFactoryData = {},
seed?: number
): Promise<CustomerGroup> => {
if (typeof seed !== "undefined") {
faker.seed(seed)
}
const manager = dataSource.manager
const customerGroupId =
data.id || `simple-customer-group-${Math.random() * 1000}`
const c = manager.create(CustomerGroup, {
id: customerGroupId,
name: data.name || faker.company.companyName(),
})
const group = await manager.save(c)
return group
}