Skip to content

Commit

Permalink
Improved coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanvamsi3 committed Oct 6, 2017
1 parent 24fb7ca commit 6b24a84
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
4 changes: 0 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ let mode = numbers => {
};

let standardDeviation = numbers => {
if (!Array.isArray(numbers)) {
return null;
}

return Math.sqrt(variance(numbers));
};

Expand Down
24 changes: 22 additions & 2 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,33 @@ var stats = require('../index');

describe('#stats', function() {
it('Median', function() {
var result = stats.median([1,2,3]);
var result = stats.median([1, 2, 3]);
expect(result).to.equal(2);
});
it('Not an array error', function() {
it('Median with even length array', function() {
var result = stats.median([1, 2, 3, 4]);
expect(result).to.equal(2.5);
});
it('Not an array error median', function() {
var result = stats.median(1);
expect(result).to.equal(null);
});
it('Not an array error mean', function() {
var result = stats.mean(1);
expect(result).to.equal(null);
});
it('Not an array error mode', function() {
var result = stats.mode(1);
expect(result).to.equal(null);
});
it('Not an array error variance', function() {
var result = stats.variance(1);
expect(result).to.equal(null);
});
it('Not an array error harmonic mean', function() {
var result = stats.harmonicMean(1);
expect(result).to.equal(null);
});
it('Mode', function() {
var result = stats.mode([1, 2, 1, 3]);
expect(result[0]).to.equal(1);
Expand Down

0 comments on commit 6b24a84

Please sign in to comment.