Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Commit

Permalink
Fix .size with should as function
Browse files Browse the repository at this point in the history
  • Loading branch information
btd committed Jan 12, 2018
1 parent 7095ae5 commit 70733b9
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions lib/ext/property.js
Expand Up @@ -109,14 +109,17 @@ export default function(should, Assertion) {
}

var operator =
(props.length === 1 ? "to have property " : "to have " + (this.anyOne ? "any of " : "") + "properties ") +
props.join(", ");
(props.length === 1
? "to have property "
: "to have " + (this.anyOne ? "any of " : "") + "properties ") + props.join(", ");

this.params = { obj: this.obj, operator: operator };

//check that all properties presented
//or if we request one of them that at least one them presented
this.assert(missingProperties.length === 0 || (this.anyOne && missingProperties.length != names.length));
this.assert(
missingProperties.length === 0 || (this.anyOne && missingProperties.length != names.length)
);

// check if values in object matched expected
var valueCheckNames = Object.keys(values);
Expand All @@ -139,14 +142,17 @@ export default function(should, Assertion) {
}

operator =
(props.length === 1 ? "to have property " : "to have " + (this.anyOne ? "any of " : "") + "properties ") +
props.join(", ");
(props.length === 1
? "to have property "
: "to have " + (this.anyOne ? "any of " : "") + "properties ") + props.join(", ");

this.params = { obj: this.obj, operator: operator };

//if there is no not matched values
//or there is at least one matched
this.assert(wrongValues.length === 0 || (this.anyOne && wrongValues.length != valueCheckNames.length));
this.assert(
wrongValues.length === 0 || (this.anyOne && wrongValues.length != valueCheckNames.length)
);
}
});

Expand Down Expand Up @@ -296,7 +302,7 @@ export default function(should, Assertion) {
*/
Assertion.add("size", function(s) {
this.params = { operator: "to have size " + s };
size(this.obj).should.be.exactly(s);
should(size(this.obj)).be.exactly(s);
});

/**
Expand Down Expand Up @@ -325,7 +331,11 @@ export default function(should, Assertion) {
while (properties.length) {
currentProperty = properties.shift();
this.params = {
operator: "to have property by path " + allProps.join(", ") + " - failed on " + formatProp(currentProperty)
operator:
"to have property by path " +
allProps.join(", ") +
" - failed on " +
formatProp(currentProperty)
};
obj = obj.have.property(currentProperty);
foundProperties.push(currentProperty);
Expand Down

0 comments on commit 70733b9

Please sign in to comment.