jest-matcher-deep-close-to
Advanced tools
Comparing version 2.0.1 to 3.0.0
@@ -1,40 +0,11 @@ | ||
import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils'; | ||
import { recursiveCheck } from './recursiveCheck'; | ||
function printResponse(error, received, expected) { | ||
/* istanbul ignore next */ | ||
if (error) { | ||
return { | ||
message: () => `${matcherHint('.toBeDeepCloseTo')}\n\n` + | ||
`${error.reason}:\n` + | ||
` ${printExpected(error.expected)}\n` + | ||
'Received:\n' + | ||
` ${printReceived(error.received)}`, | ||
pass: false, | ||
}; | ||
} | ||
else { | ||
return { | ||
message: () => `${matcherHint('.not.toBeDeepCloseTo')}\n\n` + | ||
'The two objects are deeply equal:\n' + | ||
` ${printExpected(expected)}\n` + | ||
'Received:\n' + | ||
` ${printReceived(received)}`, | ||
pass: true, | ||
}; | ||
} | ||
import { printResponse } from './utils'; | ||
export function toBeDeepCloseTo(received, expected, precision = 2) { | ||
const error = recursiveCheck(received, expected, precision); | ||
return printResponse(error, received, expected, precision); | ||
} | ||
export function toBeDeepCloseTo(received, expected, decimals) { | ||
if (decimals === undefined) { | ||
decimals = 10; | ||
} | ||
const error = recursiveCheck(received, expected, decimals); | ||
return printResponse(error, received, expected); | ||
export function toMatchCloseTo(received, expected, precision = 2) { | ||
const error = recursiveCheck(received, expected, precision, false); | ||
return printResponse(error, received, expected, precision); | ||
} | ||
export function toMatchCloseTo(received, expected, decimals) { | ||
if (decimals === undefined) { | ||
decimals = 10; | ||
} | ||
const error = recursiveCheck(received, expected, decimals, false); | ||
return printResponse(error, received, expected); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFdBQVcsRUFBRSxhQUFhLEVBQUUsYUFBYSxFQUFFLE1BQU0s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RUFDbEIsUUFBa0IsRUFDbEIsU0FBUyxHQUFHLENBQUM7SUFFYixNQUFNLEtBQUssR0FBRyxjQUFjLENBQUMsUUFBUSxFQUFFLFFBQVEsRUFBRSxTQUFTLEVBQUUsS0FBSyxDQUFDLENBQUM7SUFDbkUsT0FBTyxhQUFhLENBQUMsS0FBSyxFQUFFLFFBQVEsRUFBRSxRQUFRLEVBQUUsU0FBUyxDQUFDLENBQUM7QUFDN0QsQ0FBQyJ9 |
@@ -0,9 +1,10 @@ | ||
import { calculatePrecision } from './utils'; | ||
/** | ||
* @param {number|Array} received | ||
* @param {number|Array} expected | ||
* @param {number} decimals | ||
* @param {number} precision | ||
* @param {boolean} strict equality or subsets allowed | ||
* @return {boolean|{reason, expected, received}} | ||
*/ | ||
export function recursiveCheck(received, expected, decimals, strict = true) { | ||
export function recursiveCheck(received, expected, precision, strict = true) { | ||
if (typeof received === 'number' && typeof expected === 'number') { | ||
@@ -15,3 +16,3 @@ // Received and expected are numbers | ||
: { | ||
reason: `Expected value to be (using ${decimals} decimals)`, | ||
reason: 'Expected', | ||
expected, | ||
@@ -25,3 +26,3 @@ received, | ||
: { | ||
reason: `Expected value to be`, | ||
reason: 'Expected', | ||
expected, | ||
@@ -31,3 +32,3 @@ received, | ||
} | ||
else if (Math.abs(received - expected) <= Math.pow(10, -decimals)) { | ||
else if (Math.abs(received - expected) <= calculatePrecision(precision)) { | ||
return false; | ||
@@ -37,5 +38,6 @@ } | ||
return { | ||
reason: `Expected value to be (using ${decimals} decimals)`, | ||
reason: 'Expected', | ||
expected, | ||
received, | ||
diff: Math.abs(received - expected), | ||
}; | ||
@@ -58,18 +60,28 @@ } | ||
} | ||
else if (Array.isArray(received) && Array.isArray(expected)) { | ||
else if (isArray(received) && isArray(expected)) { | ||
// Received and expected are arrays | ||
if (received.length !== expected.length) { | ||
const receivedLength = received.length; | ||
const expectedLength = expected.length; | ||
if (receivedLength !== expectedLength) { | ||
return { | ||
reason: 'The arrays length does not match', | ||
expected: expected.length, | ||
received: received.length, | ||
expected: expectedLength, | ||
received: receivedLength, | ||
}; | ||
} | ||
for (let i = 0; i < received.length; i++) { | ||
const error = recursiveCheck(received[i], expected[i], decimals, strict); | ||
if (error) | ||
return error; | ||
for (let i = 0; i < receivedLength; i++) { | ||
const error = recursiveCheck(received[i], expected[i], precision, strict); | ||
if (error) { | ||
return { ...error, index: i }; | ||
} | ||
} | ||
return false; | ||
} | ||
else if (expected === undefined && received === undefined) { | ||
/* Received and expected are either | ||
* 1) both explicitly set as undefined | ||
* 2) undefined properties of an object, where the received value may be implicitly undefined | ||
*/ | ||
return false; | ||
} | ||
else if (expected === null && received === null) { | ||
@@ -91,5 +103,3 @@ // Received and expected are null | ||
if (!sameLength || | ||
expectedKeys.some(function (e) { | ||
return !Object.prototype.hasOwnProperty.call(received, e); | ||
})) { | ||
expectedKeys.some((e) => !Object.prototype.hasOwnProperty.call(received, e))) { | ||
return { | ||
@@ -102,5 +112,6 @@ reason: 'The objects do not have similar keys', | ||
for (const prop in expected) { | ||
const propError = recursiveCheck(received[prop], expected[prop], decimals, strict); | ||
if (propError) | ||
return propError; | ||
const propError = recursiveCheck(received[prop], expected[prop], precision, strict); | ||
if (propError) { | ||
return { ...propError, key: prop }; | ||
} | ||
} | ||
@@ -118,2 +129,7 @@ return false; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2hlY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcmVjdXJzaXZlQ2hlY2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBY0E7Ozs7OztHQU1HO0FBQ0gsTUFBTSxVQUFVLGNBQWMsQ0FDNUIsUUFBa0IsRUFDbEIsUUFBa0IsRUFDbEIsUUFBZ0IsRUFDaEIsTUFBTSxHQUFHLElBQUk7SUFFYixJQUFJLE9BQU8sUUFBUSxLQUFLLFFBQVEsSUFBSSxPQUF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UFHLGNBQWMsQ0FDOUIsUUFBUSxDQUFDLElBQUksQ0FBQyxFQUNkLFFBQVEsQ0FBQyxJQUFJLENBQUMsRUFDZCxRQUFRLEVBQ1IsTUFBTSxDQUNQLENBQUM7WUFDRixJQUFJLFNBQVM7Z0JBQUUsT0FBTyxTQUFTLENBQUM7U0FDakM7UUFDRCxPQUFPLEtBQUssQ0FBQztLQUNkO1NBQU07UUFDTCw0QkFBNEI7UUFDNUIsT0FBTztZQUNMLE1BQU0sRUFBRSw2REFBNkQ7WUFDckUsUUFBUSxFQUFFLE9BQU8sUUFBUTtZQUN6QixRQUFRLEVBQUUsT0FBTyxRQUFRO1NBQzFCLENBQUM7S0FDSDtBQUNILENBQUMifQ== | ||
function isArray(value) { | ||
return (Array.isArray(value) || | ||
value instanceof Float32Array || | ||
value instanceof Float64Array); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2hlY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcmVjdXJzaXZlQ2hlY2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFFLGtCQUFrQixFQUFFLE1BQU0sU0FBUyxDQUFDO0FBRTdDOzs7Ozs7R0FNRztBQUNILE1BQU0sVUFBVSxjQUFjLENBQzVCLFFBQWtCLEVBQ2xCLFFBQWtCLEVBQ2xCLFNBQWlCLEVBQ2pCLE1BQU0sR0FBRyxJQUFJO0lBRWIsSUFBSSxPQUFPLFFBQVEsS0FBSyxRQUFRLElBQUksT0FBTyxRQUFRLEtBQUssUUFBUSxFQUFFO1FBQ2hFLG9DQUFvQztRQUVwQyxJQUFJLEtBQUssQ0FBQyxRQUFRLENBQUMsRUFBRTtZQUNuQixPQUFPLEtBQUssQ0FBQyxRQUFRLENBQUM7Z0JBQ3BCLENBQUMsQ0FBQyxLQUFLO2dCQUNQLENBQUMsQ0FBQztvQ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UFjLENBQzdCLFFBQTJCLENBQUMsSUFBSSxDQUFDLEVBQ2pDLFFBQTJCLENBQUMsSUFBSSxDQUFDLEVBQ2xDLFNBQVMsRUFDVCxNQUFNLENBQ1AsQ0FBQztZQUNGLElBQUksU0FBUyxFQUFFO2dCQUNiLE9BQU8sRUFBRSxHQUFHLFNBQVMsRUFBRSxHQUFHLEVBQUUsSUFBSSxFQUFFLENBQUM7YUFDcEM7U0FDRjtRQUNELE9BQU8sS0FBSyxDQUFDO0tBQ2Q7U0FBTTtRQUNMLDRCQUE0QjtRQUM1QixPQUFPO1lBQ0wsTUFBTSxFQUFFLDZEQUE2RDtZQUNyRSxRQUFRLEVBQUUsT0FBTyxRQUFRO1lBQ3pCLFFBQVEsRUFBRSxPQUFPLFFBQVE7U0FDMUIsQ0FBQztLQUNIO0FBQ0gsQ0FBQztBQUdELFNBQVMsT0FBTyxDQUFDLEtBQWU7SUFDOUIsT0FBTyxDQUNMLEtBQUssQ0FBQyxPQUFPLENBQUMsS0FBSyxDQUFDO1FBQ3BCLEtBQUssWUFBWSxZQUFZO1FBQzdCLEtBQUssWUFBWSxZQUFZLENBQzlCLENBQUM7QUFDSixDQUFDIn0= |
@@ -1,7 +0,3 @@ | ||
import { Iterable } from './recursiveCheck'; | ||
export interface MatcherResult { | ||
message: () => string; | ||
pass: boolean; | ||
} | ||
export declare function toBeDeepCloseTo(received: Iterable, expected: Iterable, decimals?: number): MatcherResult; | ||
export declare function toMatchCloseTo(received: Iterable, expected: Iterable, decimals?: number): MatcherResult; | ||
import type { Iterable, MatcherResult } from './types'; | ||
export declare function toBeDeepCloseTo(received: Iterable, expected: Iterable, precision?: number): MatcherResult; | ||
export declare function toMatchCloseTo(received: Iterable, expected: Iterable, precision?: number): MatcherResult; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const jest_matcher_utils_1 = require("jest-matcher-utils"); | ||
exports.toMatchCloseTo = exports.toBeDeepCloseTo = void 0; | ||
const recursiveCheck_1 = require("./recursiveCheck"); | ||
function printResponse(error, received, expected) { | ||
/* istanbul ignore next */ | ||
if (error) { | ||
return { | ||
message: () => `${jest_matcher_utils_1.matcherHint('.toBeDeepCloseTo')}\n\n` + | ||
`${error.reason}:\n` + | ||
` ${jest_matcher_utils_1.printExpected(error.expected)}\n` + | ||
'Received:\n' + | ||
` ${jest_matcher_utils_1.printReceived(error.received)}`, | ||
pass: false, | ||
}; | ||
} | ||
else { | ||
return { | ||
message: () => `${jest_matcher_utils_1.matcherHint('.not.toBeDeepCloseTo')}\n\n` + | ||
'The two objects are deeply equal:\n' + | ||
` ${jest_matcher_utils_1.printExpected(expected)}\n` + | ||
'Received:\n' + | ||
` ${jest_matcher_utils_1.printReceived(received)}`, | ||
pass: true, | ||
}; | ||
} | ||
const utils_1 = require("./utils"); | ||
function toBeDeepCloseTo(received, expected, precision = 2) { | ||
const error = (0, recursiveCheck_1.recursiveCheck)(received, expected, precision); | ||
return (0, utils_1.printResponse)(error, received, expected, precision); | ||
} | ||
function toBeDeepCloseTo(received, expected, decimals) { | ||
if (decimals === undefined) { | ||
decimals = 10; | ||
} | ||
const error = recursiveCheck_1.recursiveCheck(received, expected, decimals); | ||
return printResponse(error, received, expected); | ||
} | ||
exports.toBeDeepCloseTo = toBeDeepCloseTo; | ||
function toMatchCloseTo(received, expected, decimals) { | ||
if (decimals === undefined) { | ||
decimals = 10; | ||
} | ||
const error = recursiveCheck_1.recursiveCheck(received, expected, decimals, false); | ||
return printResponse(error, received, expected); | ||
function toMatchCloseTo(received, expected, precision = 2) { | ||
const error = (0, recursiveCheck_1.recursiveCheck)(received, expected, precision, false); | ||
return (0, utils_1.printResponse)(error, received, expected, precision); | ||
} | ||
exports.toMatchCloseTo = toMatchCloseTo; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvaW5kZXgudHMiXSwibmFtZXM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0FBQztJQUViLE1BQU0sS0FBSyxHQUFHLElBQUEsK0JBQWMsRUFBQyxRQUFRLEVBQUUsUUFBUSxFQUFFLFNBQVMsRUFBRSxLQUFLLENBQUMsQ0FBQztJQUNuRSxPQUFPLElBQUEscUJBQWEsRUFBQyxLQUFLLEVBQUUsUUFBUSxFQUFFLFFBQVEsRUFBRSxTQUFTLENBQUMsQ0FBQztBQUM3RCxDQUFDO0FBUEQsd0NBT0MifQ== |
@@ -1,16 +0,9 @@ | ||
export declare type Iterable = number | Iterable[] | { | ||
[k: string]: Iterable; | ||
} | string | null | undefined | boolean; | ||
export interface Error { | ||
reason: string; | ||
expected: unknown; | ||
received: unknown; | ||
} | ||
import type { Iterable, Error } from './types'; | ||
/** | ||
* @param {number|Array} received | ||
* @param {number|Array} expected | ||
* @param {number} decimals | ||
* @param {number} precision | ||
* @param {boolean} strict equality or subsets allowed | ||
* @return {boolean|{reason, expected, received}} | ||
*/ | ||
export declare function recursiveCheck(received: Iterable, expected: Iterable, decimals: number, strict?: boolean): false | Error; | ||
export declare function recursiveCheck(received: Iterable, expected: Iterable, precision: number, strict?: boolean): false | Error; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.recursiveCheck = void 0; | ||
const utils_1 = require("./utils"); | ||
/** | ||
* @param {number|Array} received | ||
* @param {number|Array} expected | ||
* @param {number} decimals | ||
* @param {number} precision | ||
* @param {boolean} strict equality or subsets allowed | ||
* @return {boolean|{reason, expected, received}} | ||
*/ | ||
function recursiveCheck(received, expected, decimals, strict = true) { | ||
function recursiveCheck(received, expected, precision, strict = true) { | ||
if (typeof received === 'number' && typeof expected === 'number') { | ||
@@ -17,3 +19,3 @@ // Received and expected are numbers | ||
: { | ||
reason: `Expected value to be (using ${decimals} decimals)`, | ||
reason: 'Expected', | ||
expected, | ||
@@ -27,3 +29,3 @@ received, | ||
: { | ||
reason: `Expected value to be`, | ||
reason: 'Expected', | ||
expected, | ||
@@ -33,3 +35,3 @@ received, | ||
} | ||
else if (Math.abs(received - expected) <= Math.pow(10, -decimals)) { | ||
else if (Math.abs(received - expected) <= (0, utils_1.calculatePrecision)(precision)) { | ||
return false; | ||
@@ -39,5 +41,6 @@ } | ||
return { | ||
reason: `Expected value to be (using ${decimals} decimals)`, | ||
reason: 'Expected', | ||
expected, | ||
received, | ||
diff: Math.abs(received - expected), | ||
}; | ||
@@ -60,18 +63,28 @@ } | ||
} | ||
else if (Array.isArray(received) && Array.isArray(expected)) { | ||
else if (isArray(received) && isArray(expected)) { | ||
// Received and expected are arrays | ||
if (received.length !== expected.length) { | ||
const receivedLength = received.length; | ||
const expectedLength = expected.length; | ||
if (receivedLength !== expectedLength) { | ||
return { | ||
reason: 'The arrays length does not match', | ||
expected: expected.length, | ||
received: received.length, | ||
expected: expectedLength, | ||
received: receivedLength, | ||
}; | ||
} | ||
for (let i = 0; i < received.length; i++) { | ||
const error = recursiveCheck(received[i], expected[i], decimals, strict); | ||
if (error) | ||
return error; | ||
for (let i = 0; i < receivedLength; i++) { | ||
const error = recursiveCheck(received[i], expected[i], precision, strict); | ||
if (error) { | ||
return { ...error, index: i }; | ||
} | ||
} | ||
return false; | ||
} | ||
else if (expected === undefined && received === undefined) { | ||
/* Received and expected are either | ||
* 1) both explicitly set as undefined | ||
* 2) undefined properties of an object, where the received value may be implicitly undefined | ||
*/ | ||
return false; | ||
} | ||
else if (expected === null && received === null) { | ||
@@ -93,5 +106,3 @@ // Received and expected are null | ||
if (!sameLength || | ||
expectedKeys.some(function (e) { | ||
return !Object.prototype.hasOwnProperty.call(received, e); | ||
})) { | ||
expectedKeys.some((e) => !Object.prototype.hasOwnProperty.call(received, e))) { | ||
return { | ||
@@ -104,5 +115,6 @@ reason: 'The objects do not have similar keys', | ||
for (const prop in expected) { | ||
const propError = recursiveCheck(received[prop], expected[prop], decimals, strict); | ||
if (propError) | ||
return propError; | ||
const propError = recursiveCheck(received[prop], expected[prop], precision, strict); | ||
if (propError) { | ||
return { ...propError, key: prop }; | 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SxDQUFDLFVBQVU7WUFDWCxZQUFZLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQztnQkFDM0IsT0FBTyxDQUFDLE1BQU0sQ0FBQyxTQUFTLENBQUMsY0FBYyxDQUFDLElBQUksQ0FBQyxRQUFRLEVBQUUsQ0FBQyxDQUFDLENBQUM7WUFDNUQsQ0FBQyxDQUFDLEVBQ0Y7WUFDQSxPQUFPO2dCQUNMLE1BQU0sRUFBRSxzQ0FBc0M7Z0JBQzlDLFFBQVEsRUFBRSxZQUFZO2dCQUN0QixRQUFRLEVBQUUsWUFBWTthQUN2QixDQUFDO1NBQ0g7UUFDRCxLQUFLLE1BQU0sSUFBSSxJQUFJLFFBQVEsRUFBRTtZQUMzQixNQUFNLFNBQVMsR0FBRyxjQUFjLENBQzlCLFFBQVEsQ0FBQyxJQUFJLENBQUMsRUFDZCxRQUFRLENBQUMsSUFBSSxDQUFDLEVBQ2QsUUFBUSxFQUNSLE1BQU0sQ0FDUCxDQUFDO1lBQ0YsSUFBSSxTQUFTO2dCQUFFLE9BQU8sU0FBUyxDQUFDO1NBQ2pDO1FBQ0QsT0FBTyxLQUFLLENBQUM7S0FDZDtTQUFNO1FBQ0wsNEJBQTRCO1FBQzVCLE9BQU87WUFDTCxNQUFNLEVBQUUsNkRBQTZEO1lBQ3JFLFFBQVEsRUFBRSxPQUFPLFFBQVE7WUFDekIsUUFBUSxFQUFFLE9BQU8sUUFBUTtTQUMxQixDQUFDO0tBQ0g7QUFDSCxDQUFDO0FBaEhELHdDQWdIQyJ9 | ||
function isArray(value) { | ||
return (Array.isArray(value) || | ||
value instanceof Float32Array || | ||
value instanceof Float64Array); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicmVjdXJzaXZlQ2hlY2suanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvcmVjdXJzaXZlQ2hlY2sudHMiXSwibmFtZXMiOltdLCJtYXBwaW5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 | ||
"name": "jest-matcher-deep-close-to", | ||
"version": "2.0.1", | ||
"version": "3.0.0", | ||
"description": "Extend jest to assert arrays with approximate values", | ||
@@ -25,6 +25,7 @@ "main": "./lib/index.js", | ||
"eslint-fix": "npm run eslint -- --fix", | ||
"prepublishOnly": "npm run tsc", | ||
"test": "npm run test-coverage && npm run eslint", | ||
"test-coverage": "npm run test-only -- --coverage", | ||
"test-only": "jest", | ||
"prepublishOnly": "npm run tsc & npm run copy-dts", | ||
"copy-dts": "copyfiles -u 1 \"src/**/*.d.ts\" lib", | ||
"tsc": "npm run clean && npm run tsc-cjs && npm run tsc-esm", | ||
@@ -54,20 +55,21 @@ "tsc-cjs": "tsc --project tsconfig.cjs.json", | ||
"dependencies": { | ||
"jest-matcher-utils": "~25.4.0" | ||
"jest-matcher-utils": "~27.2.2" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "~25.2.1", | ||
"@typescript-eslint/eslint-plugin": "~2.30.0", | ||
"@typescript-eslint/parser": "~2.30.0", | ||
"eslint": "~6.8.0", | ||
"eslint-config-cheminfo": "~3.0.0", | ||
"eslint-config-cheminfo-typescript": "~5.0.0", | ||
"eslint-plugin-import": "~2.20.2", | ||
"eslint-plugin-jest": "~23.8.2", | ||
"eslint-plugin-prettier": "~3.1.3", | ||
"jest": "~25.4.0", | ||
"prettier": "~2.0.5", | ||
"@types/jest": "~27.0.2", | ||
"@typescript-eslint/eslint-plugin": "~4.32.0", | ||
"@typescript-eslint/parser": "~4.32.0", | ||
"copyfiles": "^2.4.1", | ||
"eslint": "~7.32.0", | ||
"eslint-config-cheminfo": "~5.5.0", | ||
"eslint-config-cheminfo-typescript": "~8.0.9", | ||
"eslint-plugin-import": "~2.24.2", | ||
"eslint-plugin-jest": "~24.4.2", | ||
"eslint-plugin-prettier": "~4.0.0", | ||
"jest": "~27.2.2", | ||
"prettier": "~2.4.1", | ||
"rimraf": "~3.0.2", | ||
"ts-jest": "~25.4.0", | ||
"typescript": "~3.8.3" | ||
"ts-jest": "~27.0.5", | ||
"typescript": "~4.4.3" | ||
} | ||
} |
@@ -11,3 +11,3 @@ # jest-matcher-deep-close-to | ||
`$ npm install --save jest-matcher-deep-close-to` | ||
`$ npm i -D jest-matcher-deep-close-to` | ||
@@ -14,0 +14,0 @@ ## Usage |
@@ -1,49 +0,12 @@ | ||
import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils'; | ||
import { recursiveCheck } from './recursiveCheck'; | ||
import type { Iterable, MatcherResult } from './types'; | ||
import { printResponse } from './utils'; | ||
import { recursiveCheck, Iterable, Error } from './recursiveCheck'; | ||
export interface MatcherResult { | ||
message: () => string; | ||
pass: boolean; | ||
} | ||
function printResponse( | ||
error: false | Error, | ||
received: Iterable, | ||
expected: Iterable, | ||
): MatcherResult { | ||
/* istanbul ignore next */ | ||
if (error) { | ||
return { | ||
message: () => | ||
`${matcherHint('.toBeDeepCloseTo')}\n\n` + | ||
`${error.reason}:\n` + | ||
` ${printExpected(error.expected)}\n` + | ||
'Received:\n' + | ||
` ${printReceived(error.received)}`, | ||
pass: false, | ||
}; | ||
} else { | ||
return { | ||
message: () => | ||
`${matcherHint('.not.toBeDeepCloseTo')}\n\n` + | ||
'The two objects are deeply equal:\n' + | ||
` ${printExpected(expected)}\n` + | ||
'Received:\n' + | ||
` ${printReceived(received)}`, | ||
pass: true, | ||
}; | ||
} | ||
} | ||
export function toBeDeepCloseTo( | ||
received: Iterable, | ||
expected: Iterable, | ||
decimals?: number, | ||
precision = 2, | ||
): MatcherResult { | ||
if (decimals === undefined) { | ||
decimals = 10; | ||
} | ||
const error = recursiveCheck(received, expected, decimals); | ||
return printResponse(error, received, expected); | ||
const error = recursiveCheck(received, expected, precision); | ||
return printResponse(error, received, expected, precision); | ||
} | ||
@@ -54,9 +17,6 @@ | ||
expected: Iterable, | ||
decimals?: number, | ||
precision = 2, | ||
): MatcherResult { | ||
if (decimals === undefined) { | ||
decimals = 10; | ||
} | ||
const error = recursiveCheck(received, expected, decimals, false); | ||
return printResponse(error, received, expected); | ||
const error = recursiveCheck(received, expected, precision, false); | ||
return printResponse(error, received, expected, precision); | ||
} |
declare namespace jest { | ||
interface IterableObject { | ||
[k: string]: Iterable; | ||
} | ||
type Iterable = | ||
| number | ||
| Iterable[] | ||
| { [k: string]: Iterable } | ||
| Float32Array | ||
| Float64Array | ||
| IterableObject | ||
| string | ||
@@ -7,0 +12,0 @@ | null |
@@ -1,14 +0,3 @@ | ||
export type Iterable = | ||
| number | ||
| Iterable[] | ||
| { [k: string]: Iterable } | ||
| string | ||
| null | ||
| undefined | ||
| boolean; | ||
export interface Error { | ||
reason: string; | ||
expected: unknown; | ||
received: unknown; | ||
} | ||
import type { Iterable, Error, IterableObject } from './types'; | ||
import { calculatePrecision } from './utils'; | ||
@@ -18,3 +7,3 @@ /** | ||
* @param {number|Array} expected | ||
* @param {number} decimals | ||
* @param {number} precision | ||
* @param {boolean} strict equality or subsets allowed | ||
@@ -26,3 +15,3 @@ * @return {boolean|{reason, expected, received}} | ||
expected: Iterable, | ||
decimals: number, | ||
precision: number, | ||
strict = true, | ||
@@ -37,3 +26,3 @@ ): false | Error { | ||
: { | ||
reason: `Expected value to be (using ${decimals} decimals)`, | ||
reason: 'Expected', | ||
expected, | ||
@@ -46,13 +35,14 @@ received, | ||
: { | ||
reason: `Expected value to be`, | ||
reason: 'Expected', | ||
expected, | ||
received, | ||
}; | ||
} else if (Math.abs(received - expected) <= Math.pow(10, -decimals)) { | ||
} else if (Math.abs(received - expected) <= calculatePrecision(precision)) { | ||
return false; | ||
} else { | ||
return { | ||
reason: `Expected value to be (using ${decimals} decimals)`, | ||
reason: 'Expected', | ||
expected, | ||
received, | ||
diff: Math.abs(received - expected), | ||
}; | ||
@@ -75,17 +65,32 @@ } | ||
} | ||
} else if (Array.isArray(received) && Array.isArray(expected)) { | ||
} else if (isArray(received) && isArray(expected)) { | ||
// Received and expected are arrays | ||
if (received.length !== expected.length) { | ||
const receivedLength = (received as ArrayType).length; | ||
const expectedLength = (expected as ArrayType).length; | ||
if (receivedLength !== expectedLength) { | ||
return { | ||
reason: 'The arrays length does not match', | ||
expected: expected.length, | ||
received: received.length, | ||
expected: expectedLength, | ||
received: receivedLength, | ||
}; | ||
} | ||
for (let i = 0; i < received.length; i++) { | ||
const error = recursiveCheck(received[i], expected[i], decimals, strict); | ||
if (error) return error; | ||
for (let i = 0; i < receivedLength; i++) { | ||
const error = recursiveCheck( | ||
(received as ArrayType)[i], | ||
(expected as ArrayType)[i], | ||
precision, | ||
strict, | ||
); | ||
if (error) { | ||
return { ...error, index: i }; | ||
} | ||
} | ||
return false; | ||
} else if (expected === undefined && received === undefined) { | ||
/* Received and expected are either | ||
* 1) both explicitly set as undefined | ||
* 2) undefined properties of an object, where the received value may be implicitly undefined | ||
*/ | ||
return false; | ||
} else if (expected === null && received === null) { | ||
@@ -111,5 +116,5 @@ // Received and expected are null | ||
!sameLength || | ||
expectedKeys.some(function (e) { | ||
return !Object.prototype.hasOwnProperty.call(received, e); | ||
}) | ||
expectedKeys.some( | ||
(e) => !Object.prototype.hasOwnProperty.call(received, e), | ||
) | ||
) { | ||
@@ -124,8 +129,10 @@ return { | ||
const propError = recursiveCheck( | ||
received[prop], | ||
expected[prop], | ||
decimals, | ||
(received as IterableObject)[prop], | ||
(expected as IterableObject)[prop], | ||
precision, | ||
strict, | ||
); | ||
if (propError) return propError; | ||
if (propError) { | ||
return { ...propError, key: prop }; | ||
} | ||
} | ||
@@ -142,1 +149,10 @@ return false; | ||
} | ||
type ArrayType = Float32Array | Float64Array | Array<Iterable>; | ||
function isArray(value: Iterable): boolean { | ||
return ( | ||
Array.isArray(value) || | ||
value instanceof Float32Array || | ||
value instanceof Float64Array | ||
); | ||
} |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
49582
21
750
15
1
+ Addedansi-styles@5.2.0(transitive)
+ Addedchalk@4.1.2(transitive)
+ Addeddiff-sequences@27.5.1(transitive)
+ Addedjest-diff@27.5.1(transitive)
+ Addedjest-get-type@27.5.1(transitive)
+ Addedjest-matcher-utils@27.2.5(transitive)
+ Addedpretty-format@27.5.1(transitive)
+ Addedreact-is@17.0.2(transitive)
- Removed@jest/types@25.5.0(transitive)
- Removed@types/istanbul-lib-coverage@2.0.6(transitive)
- Removed@types/istanbul-lib-report@3.0.3(transitive)
- Removed@types/istanbul-reports@1.1.2(transitive)
- Removed@types/yargs@15.0.19(transitive)
- Removed@types/yargs-parser@21.0.3(transitive)
- Removedchalk@3.0.0(transitive)
- Removeddiff-sequences@25.2.6(transitive)
- Removedjest-diff@25.5.0(transitive)
- Removedjest-get-type@25.2.6(transitive)
- Removedjest-matcher-utils@25.4.0(transitive)
- Removedpretty-format@25.5.0(transitive)
- Removedreact-is@16.13.1(transitive)
Updatedjest-matcher-utils@~27.2.2