unexpected
Advanced tools
Comparing version 5.1.1 to 5.1.2
@@ -16,9 +16,9 @@ var utils = require('./utils'); | ||
expect.addAssertion('[not] to be', function (expect, subject, value) { | ||
if (typeof subject === 'string' && typeof value === 'string') { | ||
expect(subject, '[not] to equal', value); | ||
} else { | ||
expect(subject === value, '[not] to be truthy'); | ||
} | ||
expect(subject === value, '[not] to be truthy'); | ||
}); | ||
expect.addAssertion('string', '[not] to be', function (expect, subject, value) { | ||
expect(subject, '[not] to equal', value); | ||
}); | ||
expect.addAssertion('boolean', '[not] to be true', function (expect, subject) { | ||
@@ -615,3 +615,3 @@ expect(subject, '[not] to be', true); | ||
} | ||
var isInlineDiff = false; | ||
var isInlineDiff = true; | ||
if (conflicting) { | ||
@@ -624,2 +624,3 @@ if (!(key in value)) { | ||
var keyDiff = conflicting.createDiff && conflicting.createDiff(output.clone(), diff, inspect, equal); | ||
isInlineDiff = !keyDiff || keyDiff.inline ; | ||
if (value[key] && value[key]._expectIt) { | ||
@@ -644,3 +645,2 @@ if (keyDiff && keyDiff.diff) { | ||
} else { | ||
isInlineDiff = true; | ||
valueOutput = keyDiff.diff; | ||
@@ -663,2 +663,3 @@ } | ||
valueOutput.text(last ? '' : ','); | ||
if (isInlineDiff) { | ||
@@ -665,0 +666,0 @@ this.append(valueOutput); |
@@ -465,3 +465,4 @@ /*global setTimeout*/ | ||
function handleNestedExpects(expect, e, assertion) { | ||
switch (assertion.errorMode) { | ||
var errorMode = e.errorMode || assertion.errorMode; | ||
switch (errorMode) { | ||
case 'nested': | ||
@@ -638,3 +639,3 @@ var comparison = buildDiff(expect, e); | ||
} else { | ||
var errorMessage; | ||
var errorMessage = this.output.clone(); | ||
var definedForIncompatibleTypes = this.types.filter(function (type) { | ||
@@ -644,11 +645,17 @@ return this.assertions[type.name][testDescriptionString]; | ||
if (definedForIncompatibleTypes.length > 0) { | ||
errorMessage = | ||
'The assertion "' + testDescriptionString + '" is not defined for the type "' + matchingType.name + | ||
'", but it is defined for '; | ||
errorMessage.error('The assertion "').strings(testDescriptionString) | ||
.error('" is not defined for the type "').strings(matchingType.name).error('",').nl() | ||
.error('but it is defined for '); | ||
if (definedForIncompatibleTypes.length === 1) { | ||
errorMessage += 'the type "' + definedForIncompatibleTypes[0].name + '"'; | ||
errorMessage.error('the type "').strings(definedForIncompatibleTypes[0].name).error('"'); | ||
} else { | ||
errorMessage += 'these types: ' + definedForIncompatibleTypes.map(function (incompatibleType) { | ||
return '"' + incompatibleType.name + '"'; | ||
}).join(', '); | ||
errorMessage.error('these types: '); | ||
definedForIncompatibleTypes.forEach(function (incompatibleType, index) { | ||
if (index > 0) { | ||
errorMessage.error(', '); | ||
} | ||
errorMessage.error('"').strings(incompatibleType.name).error('"'); | ||
}); | ||
} | ||
@@ -675,8 +682,13 @@ } else { | ||
}); | ||
errorMessage = | ||
'Unknown assertion "' + testDescriptionString + '", ' + | ||
'did you mean: "' + assertionsWithScore[0].assertion + '"'; | ||
errorMessage.error('Unknown assertion "').strings(testDescriptionString) | ||
.error('", did you mean: "').strings(assertionsWithScore[0].assertion).error('"'); | ||
} | ||
throw truncateStack(new Error(errorMessage), this.expect); | ||
var missingAssertionError = new Error(); | ||
missingAssertionError.output = errorMessage; | ||
missingAssertionError._isUnexpected = true; | ||
missingAssertionError.errorMode = 'bubble'; | ||
if (nestingLevel === 0) { | ||
this.setErrorMessage(missingAssertionError); | ||
} | ||
this.fail(missingAssertionError); | ||
} | ||
@@ -683,0 +695,0 @@ }; |
{ | ||
"name": "unexpected", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -996,9 +996,9 @@ # Unexpected | ||
## Credits | ||
## License | ||
MIT, see the `LICENSE` file for details | ||
### 3rd-party | ||
### Credits | ||
Heavily borrows from [expect.js](https://github.com/LearnBoost/expect.js) by | ||
Guillermo Rauch - MIT. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
630182
26
11398