Skip to content

Commit

Permalink
Update jsdoc for ScenarioData type (#10066)
Browse files Browse the repository at this point in the history
Co-authored-by: Tobbe Lundberg <tobbe@tlundberg.com>
  • Loading branch information
2 people authored and jtoar committed Feb 27, 2024
1 parent ab316ef commit 1bf5e87
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 37 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

- Update jsdoc for ScenarioData type (#29166)

Fix formatting of JSDocs in `scenario.ts`

- fix(render): reduce memory and handle server file

This PR improves Render deploys by reducing memory consumption and fixing it so that it uses the server file if it's present.
Expand Down
80 changes: 43 additions & 37 deletions packages/testing/src/api/scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,51 @@ import type { A } from 'ts-toolbelt'

/**
* Use this function to define your scenario.
*
* @example
* export const standard = defineScenario({
user: {
dom: {
name: 'Dom Saadi',
email: 'dom@redwoodjs.com'
}
},
})
/* @example
* export const standard = defineScenario<Prisma.CreateUserArgs>({
user: {
dom: {
name: 'Dom Saadi',
email: 'dom@redwoodjs.com'
}
},
})
*/
* user: {
* dom: {
* name: 'Dom Saadi',
* email: 'dom@redwoodjs.com',
* },
* },
* })
*
* @example
* export const standard = defineScenario<Prisma.CreateUserArgs>({
* user: {
* dom: {
* name: 'Dom Saadi',
* email: 'dom@redwoodjs.com',
* },
* },
* })
*/
export const defineScenario: DefineScenario = (data) => {
return data
}

/**
* @example {
* dannyUser: {data :{
* id: 1,
* name: 'Danny',}
* }}
*
* @example
* krisUser: (scenario) => {
* return {
* data: {
* id: 2,
* name: 'Kris',
* }
* }
* {
* dannyUser: {
* data: {
* id: 1,
* name: 'Danny',
* },
* },
* }
*
* @example
* krisUser: (scenario) => {
* return {
* data: {
* id: 2,
* name: 'Kris',
* },
* }
* }
*/
type ScenarioDefinitionMap<
PrismaCreateType extends { data: any },
Expand Down Expand Up @@ -85,20 +91,20 @@ export interface DefineScenario {
* import { Product } from '@prisma/client'
*
* // If you scenario looks like this:
* * export const standard = defineScenario({
* product: {
* shirt: {
* id: 55,
* price: 10
* }
* export const standard = defineScenario({
* product: {
* shirt: {
* id: 55,
* price: 10,
* },
* },
* })
*
* // Export the StandardScenario type as
* export StandardScenario = ScenarioData<Product, 'product'>
*
* // You can also define each of the keys in your scenario, so you get stricter type checking
* export StandardScenario = ScenarioData<Product, 'product', 'shirt'>
*
*/
export declare type ScenarioData<
TModel, // the prisma model, imported from @prisma/client e.g. "Product"
Expand Down

0 comments on commit 1bf5e87

Please sign in to comment.