UNPKG

bitcore-node

Version:

A blockchain indexing node with extended capabilities using bitcore

86 lines 3.91 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); const utils = __importStar(require("../../../src/utils")); const chai_1 = require("chai"); describe('Utils', function () { describe('range', function () { it('should return an array of ascending numbers if start < end', function () { const result = utils.range(23, 35); (0, chai_1.expect)(result).to.deep.equal([23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]); }); it('should return an array of descending numbers if start > end', function () { const result = utils.range(7, 1); (0, chai_1.expect)(result).to.deep.equal([7, 6, 5, 4, 3, 2]); }); it('should handle negative start', function () { const result = utils.range(-5, 3); (0, chai_1.expect)(result).to.deep.equal([-5, -4, -3, -2, -1, 0, 1, 2]); }); it('should handle negative end', function () { const result = utils.range(0, -6); (0, chai_1.expect)(result).to.deep.equal([0, -1, -2, -3, -4, -5]); }); it('should handle negative start and end', function () { const result = utils.range(-5, -10); (0, chai_1.expect)(result).to.deep.equal([-5, -6, -7, -8, -9]); }); it('should handle negative params with start < end', function () { const result = utils.range(-5, -1); (0, chai_1.expect)(result).to.deep.equal([-5, -4, -3, -2]); }); it('should handle negative params with start > end', function () { const result = utils.range(-1, -5); (0, chai_1.expect)(result).to.deep.equal([-1, -2, -3, -4]); }); it('should handle optional end param', function () { const result = utils.range(5); (0, chai_1.expect)(result).to.deep.equal([0, 1, 2, 3, 4]); }); it('should handle optional end param with negative start', function () { const result = utils.range(-5); (0, chai_1.expect)(result).to.deep.equal([0, -1, -2, -3, -4]); }); it('should return an empty array if start equals end', function () { const result = utils.range(5, 5); (0, chai_1.expect)(result).to.deep.equal([]); }); it('should return an empty array if no params given', function () { const result = utils.range(); (0, chai_1.expect)(result).to.deep.equal([]); }); }); }); //# sourceMappingURL=index.unit.js.map