Test migration to jest by hand
Apparently using regular expressions is way easier.
This commit is contained in:
3
test/percentile/percentile.js
Normal file
3
test/percentile/percentile.js
Normal file
@ -0,0 +1,3 @@
|
||||
const percentile = (arr, val) =>
|
||||
100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length;
|
||||
module.exports = percentile;
|
||||
9
test/percentile/percentile.test.js
Normal file
9
test/percentile/percentile.test.js
Normal file
@ -0,0 +1,9 @@
|
||||
const expect = require('expect');
|
||||
const percentile = require('./percentile.js');
|
||||
|
||||
|
||||
test('percentile is a Function', () => {
|
||||
expect(percentile).toBeInstanceOf(Function);
|
||||
});
|
||||
t.equal(percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6), 55, "Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.");
|
||||
|
||||
Reference in New Issue
Block a user