Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

prisma-mock

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-mock - npm Package Compare versions

Comparing version 0.6.0 to 0.7.0

lib/utils/getNestedValue.d.ts

83

lib/index.js

@@ -25,2 +25,5 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -33,2 +36,3 @@ const client_1 = require("@prisma/client");

const deepCopy_1 = require("./utils/deepCopy");
const getNestedValue_1 = __importDefault(require("./utils/getNestedValue"));
function IsFieldDefault(f) {

@@ -625,4 +629,23 @@ return f.name !== undefined;

}
if ("path" in matchFilter) {
val = (0, getNestedValue_1.default)(matchFilter.path, val);
}
if ("equals" in matchFilter && match) {
match = (0, deepEqual_1.deepEqual)(matchFilter.equals, val);
// match = deepEqual(matchFilter.equals, val)
if (matchFilter.equals === client_1.Prisma.DbNull) {
if (val === client_1.Prisma.DbNull) {
}
match = val === client_1.Prisma.DbNull;
}
else if (matchFilter.equals === client_1.Prisma.AnyNull) {
match = val === client_1.Prisma.DbNull || val === client_1.Prisma.JsonNull;
}
else {
if (val === client_1.Prisma.DbNull) {
match = false;
}
else {
match = (0, deepEqual_1.deepEqual)(matchFilter.equals, val);
}
}
}

@@ -632,2 +655,29 @@ if ("startsWith" in matchFilter && match) {

}
if ("string_starts_with" in matchFilter && match) {
match = val?.indexOf(matchFilter.string_starts_with) === 0;
}
if ("array_contains" in matchFilter && match) {
if (Array.isArray(val)) {
for (const item of matchFilter.array_contains) {
let hasMatch = false;
for (const i of val) {
if ((0, deepEqual_1.deepEqual)(item, i))
hasMatch = true;
}
if (!hasMatch) {
match = false;
break;
}
}
}
else {
match = false;
}
}
if ("string_ends_with" in matchFilter && match) {
match = val ? val.indexOf(matchFilter.string_ends_with) === val.length - matchFilter.string_ends_with.length : false;
}
if ("string_contains" in matchFilter && match) {
match = val ? val?.indexOf(matchFilter.string_contains) !== -1 : false;
}
if ("endsWith" in matchFilter && match) {

@@ -657,3 +707,13 @@ match =

if ("not" in matchFilter && match) {
match = !(0, deepEqual_1.deepEqual)(matchFilter.not, val);
if (matchFilter.not === client_1.Prisma.DbNull) {
match = val !== client_1.Prisma.DbNull;
}
else {
if (val === client_1.Prisma.DbNull) {
match = false;
}
else {
match = !(0, deepEqual_1.deepEqual)(matchFilter.not, val);
}
}
}

@@ -663,4 +723,7 @@ if ("notIn" in matchFilter && match) {

}
if (!match)
if (!match) {
console.log("has no match", item);
return false;
}
console.log("has match", item);
}

@@ -671,2 +734,3 @@ else if (val !== filter) {

}
console.log("matchFilter", filter, item, child, filter?.equals === item[child]);
return true;

@@ -748,2 +812,15 @@ };

}
// Replace nulls
res = res.map((item) => {
const newItem = {};
Object.keys(item).forEach((key) => {
if (item[key] === client_1.Prisma.JsonNull || item[key] === client_1.Prisma.DbNull) {
newItem[key] = null;
}
else {
newItem[key] = item[key];
}
});
return newItem;
});
return res;

@@ -750,0 +827,0 @@ };

2

package.json
{
"name": "prisma-mock",
"version": "0.6.0",
"version": "0.7.0",
"description": "Mock prisma for unit testing database",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc