Skip to content

Commit

Permalink
more stats tests
Browse files Browse the repository at this point in the history
  • Loading branch information
catdad committed Apr 14, 2016
1 parent c87559c commit 1805b59
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions test/stats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('[stats]', function() {
{},
function() {}
].forEach(function(val) {
it('throws if given invalid data value "' + (JSON.stringify(val) || val.toString()) + '"', function() {
it('throws if given invalid data value: ' + (JSON.stringify(val) || val.toString()), function() {
function guilty() {
func(val);
}
Expand Down Expand Up @@ -69,13 +69,23 @@ describe('[stats]', function() {
stats.percentile(val, 50);
});

[-1, 101].forEach(function(n) {
it('throws for invalid n value ' + n, function() {
function guilty() {
function validateInvalidN(n, error) {
function guilty() {
stats.percentile(data, n);
}

expect(guilty).to.throw('n must be between 0 and 100');
expect(guilty).to.throw(error);
}

[-1, 101].forEach(function(n) {
it('throws for out-of-range n value: ' + n, function() {
validateInvalidN(n, 'n must be between 0 and 100');
});
});

[null, '5', {}, [], function() {}].forEach(function(n) {
it('throws for invalid n value: ' + (JSON.stringify(n) || n.toString()), function() {
validateInvalidN(n, 'n is not a number');
});
});
});
Expand Down

0 comments on commit 1805b59

Please sign in to comment.