Skip to content

Commit

Permalink
groupby tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgraul committed Sep 3, 2012
1 parent 72a252c commit ba3c30b
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/unit/derived.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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");
});
});

Expand Down

0 comments on commit ba3c30b

Please sign in to comment.