Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jsdoc for ScenarioData type #10066

Merged
merged 3 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(deps): update opentelemetry-js monorepo (#10065)

Updates our opentelemetry packages. This is a breaking change for users of
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
Loading