prisma-mock 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +12 -0
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -78,7 +78,19 @@ const createPrismaMock = (data = {}, datamodel, client = (0, jest_mock_extended_
78
78
  });
79
79
  const Delegate = (prop, model) => {
80
80
  const sortFunc = (orderBy) => (a, b) => {
81
+ if (Array.isArray(orderBy)) {
82
+ for (const order of orderBy) {
83
+ const res = sortFunc(order)(a, b);
84
+ if (res !== 0) {
85
+ return res;
86
+ }
87
+ }
88
+ return 0;
89
+ }
81
90
  const keys = Object.keys(orderBy);
91
+ if (keys.length > 1) {
92
+ throw new runtime_1.PrismaClientValidationError(`Argument orderBy of needs exactly one argument, but you provided ${keys.join(' and ')}. Please choose one.`);
93
+ }
82
94
  const incl = includes({ include: keys.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: true })), {}) });
83
95
  for (const key of keys) {
84
96
  const dir = orderBy[key];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-mock",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Mock prisma for unit testing database",
5
5
  "main": "lib/index.js",
6
6
  "repository": "https://github.com/demonsters/prisma-mock",