Permalink
Browse files

groupby tests

  • Loading branch information...
1 parent 72a252c commit ba3c30b6bfd7f5138e74fcfb60689d92f7c95f96 @alexgraul alexgraul committed Sep 3, 2012
Showing with 6 additions and 3 deletions.
  1. +6 −3 test/unit/derived.js
@@ -169,12 +169,12 @@
{
name : "state",
type : "string",
- data : ["AZ", "AZ", "AZ", "MA", "MA", "MA"]
+ data : ["AZ", "AZ", "AZ", "MA", "MA", "MA", "AZ", "MA", "MA"]
},
{
name : "count",
type : "number",
- data : [1,2,3,4,5,6]
+ data : [1,2,3,4,5,6,null,null,undefined]
},
{
name : "anothercount",
@@ -318,14 +318,17 @@
["count", "anothercount"], {
method : function(array) {
return _.reduce(array, function(memo, num){
+ if ( _.isUndefined(num) || _.isNull(num) ) {
+ num = 1;
+ }
return memo * num;
}, 1);
}
});
ok(_.isEqual(groupedData._columns[2].data, ["AZ", "MA"]), "states correct");
ok(_.isEqual(groupedData._columns[3].data, [6,120]), "counts correct");
- ok(_.isEqual(groupedData._columns[4].data, [6000,120000]), "anothercounts correct" + groupedData._columns[3].data);
+ ok(_.isEqual(groupedData._columns[4].data, [6000,120000]), "anothercounts correct");
});
});

0 comments on commit ba3c30b

Please sign in to comment.