Uname: Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
Software: LiteSpeed
PHP version: 8.1.31 [ PHP INFO ] PHP os: Linux
Server Ip: 162.213.251.212
Your Ip: 3.147.63.208
User: allssztx (535) | Group: allssztx (533)
Safe Mode: OFF
Disable Function:
NONE

name : merge-sort.js
"use strict";

var _require = require("../utils.js"),
  expect = _require.expect;
var mergesort = require("../../merge-sort.js");
describe("Mergesort", function () {
  it("should work with simple", function () {
    var sorted = mergesort([[{
      offset: 1
    }, {
      offset: 4
    }], [{
      offset: 2
    }, {
      offset: 3
    }]]);
    var offsets = sorted.map(function (_ref) {
      var offset = _ref.offset;
      return offset;
    });
    expect(offsets).to.deep.equal([1, 2, 3, 4]);
  });
  it("should work even when having first array be the smallest values", function () {
    // In previous versions, this simple example would fail with the
    // message : `Cannot read property 'offset' of undefined`
    var sorted = mergesort([[{
      offset: 1
    }, {
      offset: 2
    }], [{
      offset: 4
    }, {
      offset: 5
    }], [{
      offset: 3
    }, {
      offset: 6
    }]]);
    var offsets = sorted.map(function (_ref2) {
      var offset = _ref2.offset;
      return offset;
    });
    expect(offsets).to.deep.equal([1, 2, 3, 4, 5, 6]);
  });
  it("should work for complex case with empty values", function () {
    var sorted = mergesort([[{
      offset: 2
    }, {
      offset: 6
    }], [{
      offset: 1
    }, {
      offset: 4
    }], [], [{
      offset: 7
    }, {
      offset: 8
    }], [], [], [{
      offset: 3
    }, {
      offset: 5
    }], []]);
    var offsets = sorted.map(function (_ref3) {
      var offset = _ref3.offset;
      return offset;
    });
    expect(offsets).to.deep.equal([1, 2, 3, 4, 5, 6, 7, 8]);
  });
});
© 2025 GrazzMean-Shell