UNPKG

@lou.codes/test

Version:

✅ Equality test with enforced readability

19 lines (18 loc) 945 B
import { foregroundRed } from "@lou.codes/ansi"; import { CREATE, DELETE, UPDATE } from "@lou.codes/diff"; import { EXCEPTION } from "./constants.js"; import { formatPropertyPath } from "./formatPropertyPath.js"; import { formatValue } from "./formatValue.js"; /** * Dictionary `Difference` kind->formatter. * * @category Output */ export const stringifyDifferenceDictionary = { [CREATE]: difference => `${formatPropertyPath(difference.path)} was set with value ${formatValue(difference.right)}.`, [DELETE]: difference => `${formatPropertyPath(difference.path)} is missing.`, [EXCEPTION]: difference => foregroundRed `there was an uncaught error: ${difference.error instanceof Error ? difference.error.message : difference.error}.`, [UPDATE]: difference => `${formatPropertyPath(difference.path)} has the wrong value. Wanted ${formatValue(difference.left)} but received ${formatValue(difference.right)}.`, };