Comparing version
@@ -6,4 +6,4 @@ export interface ValidationResult { | ||
negatedReason: string; | ||
actual?: string; | ||
expected?: string; | ||
actual?: unknown; | ||
expected?: unknown; | ||
} | ||
@@ -10,0 +10,0 @@ export interface ControlOptions { |
@@ -5,2 +5,3 @@ "use strict"; | ||
const errors_1 = require("./errors"); | ||
const format_1 = require("./format"); | ||
class Control { | ||
@@ -15,4 +16,3 @@ constructor(options) { | ||
stack: this._location.stack, | ||
actual: result.actual, | ||
expected: result.expected, | ||
...formatActualAndExpected(result), | ||
}); | ||
@@ -25,4 +25,3 @@ } | ||
stack: this._location.stack, | ||
actual: result.actual, | ||
expected: result.expected, | ||
...formatActualAndExpected(result), | ||
}); | ||
@@ -39,2 +38,15 @@ }; | ||
exports.Control = Control; | ||
function formatActualAndExpected(result) { | ||
if (!('actual' in result && 'expected' in result)) { | ||
return {}; | ||
} | ||
if (typeof result.actual === 'string' && | ||
typeof result.expected === 'string') { | ||
return { actual: result.actual, expected: result.expected }; | ||
} | ||
return { | ||
actual: (0, format_1.format)(result.actual, null), | ||
expected: (0, format_1.format)(result.expected, result.actual), | ||
}; | ||
} | ||
//# sourceMappingURL=Control.js.map |
@@ -33,4 +33,4 @@ "use strict"; | ||
negatedReason: `The passed arguments ${actualInline} are equal to ${expectedInline}, but were expected not to be equal.`, | ||
actual: (0, format_1.format)(actual, null), | ||
expected: (0, format_1.format)(expected, actual), | ||
actual, | ||
expected, | ||
}); | ||
@@ -37,0 +37,0 @@ } |
@@ -26,4 +26,4 @@ "use strict"; | ||
negatedReason: '', | ||
actual: (0, format_1.format)(control.actual.length, null), | ||
expected: (0, format_1.format)(expected.length, control.actual.length), | ||
actual: control.actual.length, | ||
expected: expected.length, | ||
}); | ||
@@ -46,4 +46,4 @@ } | ||
negatedReason: `The value ${actualInline} is unsorted equal to ${expectedInline}, but it was expected not to be unsorted equal.`, | ||
actual: (0, format_1.format)(control.actual, null), | ||
expected: (0, format_1.format)(reordered, control.actual), | ||
actual: control.actual, | ||
expected: reordered, | ||
}); | ||
@@ -50,0 +50,0 @@ } |
@@ -15,4 +15,4 @@ "use strict"; | ||
negatedReason: `The value ${actualInline} has length ${expectedInline}, but it was expected not to.`, | ||
actual: (0, format_1.format)(getLength(control.actual), null), | ||
expected: (0, format_1.format)(expected, null), | ||
actual: getLength(control.actual), | ||
expected: expected, | ||
}); | ||
@@ -19,0 +19,0 @@ } |
@@ -51,4 +51,4 @@ "use strict"; | ||
negatedReason: `${sentenceStart} a message matching ${messageInline}, but it was expected not to.`, | ||
expected: (0, format_1.format)(expectedMessage, null), | ||
actual: (0, format_1.format)(getMessageProperty(thrownError), null), | ||
actual: getMessageProperty(thrownError), | ||
expected: expectedMessage, | ||
}); | ||
@@ -62,4 +62,4 @@ } | ||
negatedReason: `${sentenceStart} an instance of ${className}, but it was expected not to.`, | ||
actual: getConstructorName(thrownError), | ||
expected: className, | ||
actual: getConstructorName(thrownError), | ||
}); | ||
@@ -74,4 +74,4 @@ } | ||
negatedReason: `${sentenceStart} an instance of ${className} with the message ${messageInline}, but it was expected not to.`, | ||
actual: (0, format_1.format)(thrownError, null), | ||
expected: formatExpected(thrownError, expectedClass, expectedMessage), | ||
actual: (0, format_1.format)(thrownError, null), | ||
}); | ||
@@ -78,0 +78,0 @@ } |
@@ -15,4 +15,4 @@ "use strict"; | ||
negatedReason: `The value ${actualInline} is equal to ${expectedInline}, but it was expected not to be equal.`, | ||
actual: (0, format_1.format)(control.actual, null), | ||
expected: (0, format_1.format)(expected, control.actual), | ||
actual: control.actual, | ||
expected, | ||
}); | ||
@@ -19,0 +19,0 @@ } |
@@ -14,4 +14,4 @@ "use strict"; | ||
negatedReason: `The value ${actualInline} is the exact same value as ${expectedInline}, but it was expected not to be.`, | ||
actual: (0, format_1.format)(control.actual, null), | ||
expected: (0, format_1.format)(expected, control.actual), | ||
actual: control.actual, | ||
expected, | ||
}); | ||
@@ -18,0 +18,0 @@ } |
@@ -24,3 +24,3 @@ { | ||
"license": "MIT", | ||
"version": "0.3.0-canary.20230322T131805", | ||
"version": "0.3.0-canary.20230322T170056", | ||
"main": "./dist/index.js", | ||
@@ -27,0 +27,0 @@ "types": "./dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4935
0.24%280132
-0.06%