Files
medusa-store/integration-tests/factories/simple-publishable-api-key-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

27 lines
619 B
TypeScript

import faker from "faker"
import { DataSource } from "typeorm"
import { PublishableApiKey } from "@medusajs/medusa"
export type PublishableApiKeyData = {
id?: string
revoked_at?: Date
revoked_by?: string
created_by?: string
title?: string
}
export const simplePublishableApiKeyFactory = async (
dataSource: DataSource,
data: PublishableApiKeyData = {}
): Promise<PublishableApiKey> => {
const manager = dataSource.manager
const pubKey = manager.create(PublishableApiKey, {
...data,
title: data.title || `${faker.commerce.department()} API key`,
})
return await manager.save(pubKey)
}