Comparing version 1.0.1 to 1.1.0
12
index.js
@@ -17,3 +17,3 @@ const prettyFormat = require('pretty-format'); | ||
const listStyle = chalk.blueBright('\n → '); | ||
const maybeInline = s => (s.includes('\n') ? '\n' : ' ') + s; | ||
@@ -26,13 +26,13 @@ const deepEqual = (o1, o2) => { | ||
const v1 = o1[key], v2 = o2[key]; | ||
const keyStr = chalk.blueBright(`${path.concat(key).join('.')}`); | ||
const keyStr = path.concat(key).join('.') | ||
if (v1 === undefined && v2 === undefined) { | ||
// ignore | ||
} else if (v1 === undefined) { | ||
diffs.push(`${keyStr}:\n${chalk.greenBright(format(v2))}`); | ||
diffs.push(`${chalk.bold.red('\n → ' + keyStr)}:${maybeInline(chalk.magentaBright(format(v2)))}`); | ||
} else if (v2 === undefined) { | ||
diffs.push(`${keyStr}:\n${chalk.redBright(format(v1))}`); | ||
diffs.push(`${chalk.bold.red('\n ← ' + keyStr)}:${maybeInline(chalk.magenta(format(v1)))}`); | ||
} else if (v1 && typeof v1 === 'object' && v2 && typeof v2 === 'object') { | ||
deepEq(v1, v2, path.concat(key)); | ||
} else if (v1 !== v2) { | ||
diffs.push(`${keyStr}:\n${chalk.greenBright(format(v1))} !== ${chalk.redBright(format(v2))}`); | ||
diffs.push(`${chalk.bold.red('\n ↔ ' + keyStr)}:${maybeInline(`${chalk.magenta(format(v1))} !== ${chalk.magentaBright(format(v2))}`)}`); | ||
} | ||
@@ -44,5 +44,5 @@ }); | ||
throw new AssertionError(listStyle + diffs.join(listStyle)); | ||
throw new AssertionError(diffs.join('')); | ||
}; | ||
module.exports = deepEqual; |
{ | ||
"name": "deep-eq", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "deepEqual assertion with pretty diff", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -16,4 +16,3 @@ # deep-eq | ||
AssertionError: | ||
→ foo.ok: | ||
1 !== 2 | ||
↔ foo.ok: 1 !== 2 | ||
at .... | ||
@@ -20,0 +19,0 @@ ``` |
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
3392
26