Skip to content

Commit

Permalink
Simplify some boolean logic a bit :)
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Mar 7, 2017
1 parent 1c908b3 commit faec411
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Unexpected.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,13 @@ function calculateAssertionSpecificity(assertion) {
// expect.addAssertion(pattern, handler)
// expect.addAssertion([pattern, ...], handler)
Unexpected.prototype.addAssertion = function (patternOrPatterns, handler, childUnexpected) {
if (arguments.length > (typeof childUnexpected === 'object' && typeof childUnexpected.expect === 'function' ? 3 : 2) || typeof handler !== 'function' || (typeof patternOrPatterns !== 'string' && !Array.isArray(patternOrPatterns))) {
var maxArguments;
if (typeof childUnexpected === 'object') {
maxArguments = 3;
} else {
maxArguments = 2;
}
if (arguments.length > maxArguments || typeof handler !== 'function' || (typeof patternOrPatterns !== 'string' && !Array.isArray(patternOrPatterns))) {
var errorMessage = "Syntax: expect.addAssertion(<string|array[string]>, function (expect, subject, ...) { ... });";
if ((typeof handler === 'string' || Array.isArray(handler)) && typeof arguments[2] === 'function') {
errorMessage +=
Expand Down

0 comments on commit faec411

Please sign in to comment.