bitcore-node
Version:
A blockchain indexing node with extended capabilities using bitcore
68 lines • 3.62 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const mocha_1 = require("mocha");
const stats_1 = require("../../../src/utils/stats");
const unit_1 = require("../../helpers/unit");
(0, mocha_1.describe)('Stats Util', () => {
before(unit_1.unitBeforeHelper);
after(unit_1.unitAfterHelper);
(0, mocha_1.describe)('Quartiles of 20', () => {
const values = new Array(20).fill(0).map((_, i) => i);
it('should give back the midpoint between 0 and 5', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 1);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(2);
});
it('should give back the midpoint between 5 and 10', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 2);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(7);
});
it('should give back the midpoint between 10 and 15', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 3);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(12);
});
it('should give back the midpoint between 15 and 20', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 4);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(17);
});
});
(0, mocha_1.describe)('Quartiles of 4', () => {
const values = new Array(4).fill(0).map((_, i) => i);
it('should give back the midpoint between 0 and 1', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 1);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(0);
});
it('should give back the midpoint between 1 and 2', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 2);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(1);
});
it('should give back the midpoint between 2 and 3', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 3);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(2);
});
it('should give back the midpoint between 3 and 4', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 4);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(3);
});
});
(0, mocha_1.describe)('Quartiles of 1', () => {
const values = new Array(1).fill(0).map((_, i) => i);
it('should give back the midpoint between 0 and 0', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 1);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(0);
});
it('should give back the midpoint between 0 and 0', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 2);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(0);
});
it('should give back the midpoint between 0 and 0', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 3);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(0);
});
it('should give back the midpoint between 0 and 0', () => {
const firstQuartileMidPoint = stats_1.StatsUtil.getNthQuartileMedian(values, 4);
(0, chai_1.expect)(firstQuartileMidPoint).to.eq(0);
});
});
});
//# sourceMappingURL=stats.unit.js.map