prisma-mock
Advanced tools
Comparing version 0.3.0 to 0.3.1
@@ -17,3 +17,3 @@ import { Prisma } from "@prisma/client"; | ||
}; | ||
declare const createPrismaMock: <P>(data?: {}, datamodel?: Prisma.DMMF.Datamodel, client?: { [K in keyof P]: P[K] extends (...args: infer A) => infer B ? import("jest-mock-extended").CalledWithMock<B, A> & (P[K] extends infer T extends (...args: infer A) => infer B ? { [K_1 in keyof T]: P[K][K_1] extends (...args: infer A_1) => infer B_1 ? import("jest-mock-extended").CalledWithMock<B_1, A_1> & (P[K][K_1] extends infer T_1 extends (...args: infer A_1) => infer B_1 ? { [K_2 in keyof T_1]: P[K][K_1][K_2] extends (...args: infer A_2) => infer B_2 ? import("jest-mock-extended").CalledWithMock<B_2, A_2> & (P[K][K_1][K_2] extends infer T_2 extends (...args: infer A_2) => infer B_2 ? { [K_3 in keyof T_2]: P[K][K_1][K_2][K_3] extends (...args: infer A_3) => infer B_3 ? import("jest-mock-extended").CalledWithMock<B_3, A_3> & (P[K][K_1][K_2][K_3] extends infer T_3 extends (...args: infer A_3) => infer B_3 ? { [K_4 in keyof T_3]: P[K][K_1][K_2][K_3][K_4] extends (...args: infer A_4) => infer B_4 ? import("jest-mock-extended").CalledWithMock<B_4, A_4> & (P[K][K_1][K_2][K_3][K_4] extends infer T_4 extends (...args: infer A_4) => infer B_4 ? { [K_5 in keyof T_4]: P[K][K_1][K_2][K_3][K_4][K_5] extends (...args: infer A_5) => infer B_5 ? import("jest-mock-extended").CalledWithMock<B_5, A_5> & (P[K][K_1][K_2][K_3][K_4][K_5] extends infer T_5 extends (...args: infer A_5) => infer B_5 ? { [K_6 in keyof T_5]: P[K][K_1][K_2][K_3][K_4][K_5][K_6] extends (...args: infer A_6) => infer B_6 ? import("jest-mock-extended").CalledWithMock<B_6, A_6> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6] extends infer T_6 extends (...args: infer A_6) => infer B_6 ? { [K_7 in keyof T_6]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends (...args: infer A_7) => infer B_7 ? import("jest-mock-extended").CalledWithMock<B_7, A_7> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T_7 extends (...args: infer A_7) => infer B_7 ? { [K_8 in keyof T_7]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends (...args: infer A_8) => infer B_8 ? import("jest-mock-extended").CalledWithMock<B_8, A_8> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T_8 extends (...args: infer A_8) => infer B_8 ? { [K_9 in keyof T_8]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends (...args: infer A_9) => infer B_9 ? import("jest-mock-extended").CalledWithMock<B_9, A_9> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T_9 extends (...args: infer A_9) => infer B_9 ? { [K_10 in keyof T_9]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends (...args: infer A_10) => infer B_10 ? any : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5]>; } : never) & P[K][K_1][K_2][K_3][K_4] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4]>; } : never) & P[K][K_1][K_2][K_3] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3]>; } : never) & P[K][K_1][K_2] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2]>; } : never) & P[K][K_1] : import("jest-mock-extended").DeepMockProxy<P[K][K_1]>; } : never) & P[K] : import("jest-mock-extended").DeepMockProxy<P[K]>; } & P, options?: MockPrismaOptions) => P; | ||
declare const createPrismaMock: <P>(data?: Partial<{ [key in IsTable<Uncapitalize<IsString<keyof P>>>]: PrismaList<P, key>; }>, datamodel?: Prisma.DMMF.Datamodel, client?: { [K in keyof P]: P[K] extends (...args: infer A) => infer B ? import("jest-mock-extended").CalledWithMock<B, A> & (P[K] extends infer T extends (...args: infer A) => infer B ? { [K_1 in keyof T]: P[K][K_1] extends (...args: infer A_1) => infer B_1 ? import("jest-mock-extended").CalledWithMock<B_1, A_1> & (P[K][K_1] extends infer T_1 extends (...args: infer A_1) => infer B_1 ? { [K_2 in keyof T_1]: P[K][K_1][K_2] extends (...args: infer A_2) => infer B_2 ? import("jest-mock-extended").CalledWithMock<B_2, A_2> & (P[K][K_1][K_2] extends infer T_2 extends (...args: infer A_2) => infer B_2 ? { [K_3 in keyof T_2]: P[K][K_1][K_2][K_3] extends (...args: infer A_3) => infer B_3 ? import("jest-mock-extended").CalledWithMock<B_3, A_3> & (P[K][K_1][K_2][K_3] extends infer T_3 extends (...args: infer A_3) => infer B_3 ? { [K_4 in keyof T_3]: P[K][K_1][K_2][K_3][K_4] extends (...args: infer A_4) => infer B_4 ? import("jest-mock-extended").CalledWithMock<B_4, A_4> & (P[K][K_1][K_2][K_3][K_4] extends infer T_4 extends (...args: infer A_4) => infer B_4 ? { [K_5 in keyof T_4]: P[K][K_1][K_2][K_3][K_4][K_5] extends (...args: infer A_5) => infer B_5 ? import("jest-mock-extended").CalledWithMock<B_5, A_5> & (P[K][K_1][K_2][K_3][K_4][K_5] extends infer T_5 extends (...args: infer A_5) => infer B_5 ? { [K_6 in keyof T_5]: P[K][K_1][K_2][K_3][K_4][K_5][K_6] extends (...args: infer A_6) => infer B_6 ? import("jest-mock-extended").CalledWithMock<B_6, A_6> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6] extends infer T_6 extends (...args: infer A_6) => infer B_6 ? { [K_7 in keyof T_6]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends (...args: infer A_7) => infer B_7 ? import("jest-mock-extended").CalledWithMock<B_7, A_7> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] extends infer T_7 extends (...args: infer A_7) => infer B_7 ? { [K_8 in keyof T_7]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends (...args: infer A_8) => infer B_8 ? import("jest-mock-extended").CalledWithMock<B_8, A_8> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] extends infer T_8 extends (...args: infer A_8) => infer B_8 ? { [K_9 in keyof T_8]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends (...args: infer A_9) => infer B_9 ? import("jest-mock-extended").CalledWithMock<B_9, A_9> & (P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] extends infer T_9 extends (...args: infer A_9) => infer B_9 ? { [K_10 in keyof T_9]: P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10] extends (...args: infer A_10) => infer B_10 ? any : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9][K_10]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8][K_9]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7][K_8]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6][K_7]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5][K_6] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5][K_6]>; } : never) & P[K][K_1][K_2][K_3][K_4][K_5] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4][K_5]>; } : never) & P[K][K_1][K_2][K_3][K_4] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3][K_4]>; } : never) & P[K][K_1][K_2][K_3] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2][K_3]>; } : never) & P[K][K_1][K_2] : import("jest-mock-extended").DeepMockProxy<P[K][K_1][K_2]>; } : never) & P[K][K_1] : import("jest-mock-extended").DeepMockProxy<P[K][K_1]>; } : never) & P[K] : import("jest-mock-extended").DeepMockProxy<P[K]>; } & P, options?: MockPrismaOptions) => P; | ||
export default createPrismaMock; |
@@ -748,4 +748,7 @@ "use strict"; | ||
} | ||
const submodel = datamodel.models.find((model) => { | ||
return model.name === schema.type; | ||
}); | ||
// Get delegate for relation | ||
const delegate = Delegate(getCamelCase(schema.type), model); | ||
const delegate = Delegate(getCamelCase(schema.type), submodel); | ||
// Construct arg for relation query | ||
@@ -752,0 +755,0 @@ let subArgs = obj[key] === true ? {} : obj[key]; |
{ | ||
"name": "prisma-mock", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Mock prisma for unit testing database", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -48,2 +48,5 @@ # Prisma Mock | ||
client = mockDeep<P>(), | ||
options: { | ||
caseInsensitive?: boolean | ||
} = {} | ||
): Promise<P> | ||
@@ -206,2 +209,36 @@ ``` | ||
- TODO: $transaction (interactive) | ||
- TODO: $transaction (isolation) | ||
- TODO: $transaction (isolation) | ||
# Contribution | ||
## Requirements | ||
Create a `.env-cmdrc` file in the root of your project with the following content: | ||
```json | ||
{ | ||
"postgres": { | ||
"PROVIDER": "postgresql", | ||
"DATABASE_URL": "postgresql://postgres:postgres@localhost:5432/postgres?schema=public" | ||
} | ||
} | ||
``` | ||
## Writing Tests | ||
Create your tests in the `__tests__` directory. You can use snapshot testing with either `expect(res).toMatchSnapshot()` or `expect(res).toMatchInlineSnapshot()`. This captures the result of your tests in a snapshot, which you can use to compare agains prisma-mock results. | ||
Note: If you choose to use snapshot testing, make shore to first run your tests against the real database to create a snapshot of the expected result. | ||
## Running Tests | ||
To run tests against a postgres database, run the following command: | ||
```bash | ||
yarn run test:postgres | ||
``` | ||
To run tests against prisma-mock (in-memory database), run: | ||
```bash | ||
yarn test | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53462
1083
243