Skip to content

Commit

Permalink
Check score recursively only if both sides are objects
Browse files Browse the repository at this point in the history
Otherwise, missing sub-objects or arrays can cause an error.
  • Loading branch information
orangejulius committed Aug 5, 2015
1 parent 64d014c commit 8d8b664
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/scoreProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function scorePrimitiveProperty(expectation, result, weight) {
* through all the keys, calculating the subscores, and aggregating them
*/
function scoreProperties(expectation, result, weight) {
if (isObject(expectation)) {
if (isObject(expectation) && isObject(result)) {
weight = weight || {};
var subscores = Object.keys(expectation).map(function(property){
return scoreProperties(expectation[property], result[property], weight[property]);
Expand Down

0 comments on commit 8d8b664

Please sign in to comment.