1 | ;
|
2 | /**
|
3 | * This file is part of the @egodigital/egoose distribution.
|
4 | * Copyright (c) e.GO Digital GmbH, Aachen, Germany (https://www.e-go-digital.com/)
|
5 | *
|
6 | * @egodigital/egoose is free software: you can redistribute it and/or modify
|
7 | * it under the terms of the GNU Lesser General Public License as
|
8 | * published by the Free Software Foundation, version 3.
|
9 | *
|
10 | * @egodigital/egoose is distributed in the hope that it will be useful, but
|
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
13 | * Lesser General Public License for more details.
|
14 | *
|
15 | * You should have received a copy of the GNU Lesser General Public License
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17 | */
|
18 | Object.defineProperty(exports, "__esModule", { value: true });
|
19 | const assert = require("assert");
|
20 | const mocha_1 = require("mocha");
|
21 | const index_1 = require("../index");
|
22 | mocha_1.describe('#compareValues()', function () {
|
23 | mocha_1.describe('Array', function () {
|
24 | mocha_1.it('should return a sorted array (ascending)', function () {
|
25 | const ARR = [1, 2, 3, 0, 4];
|
26 | const RES = ARR.sort((x, y) => {
|
27 | return index_1.compareValues(x, y);
|
28 | });
|
29 | for (let i = 0; i < ARR.length; i++) {
|
30 | const ITEM = RES[i];
|
31 | assert.ok('number' === typeof ITEM);
|
32 | assert.equal(ITEM, i);
|
33 | assert.strictEqual(ITEM, i);
|
34 | }
|
35 | });
|
36 | mocha_1.it('should return a sorted array (descending)', function () {
|
37 | const ARR = [1, 2, 3, 0, 4];
|
38 | const RES = ARR.sort((x, y) => {
|
39 | return index_1.compareValues(y, x);
|
40 | });
|
41 | for (let i = 0; i < ARR.length; i++) {
|
42 | const ITEM = RES[i];
|
43 | assert.ok('number' === typeof ITEM);
|
44 | assert.equal(ITEM, ARR.length - i - 1);
|
45 | assert.strictEqual(ITEM, ARR.length - i - 1);
|
46 | }
|
47 | });
|
48 | });
|
49 | });
|
50 | //# sourceMappingURL=compareValues.js.map |
\ | No newline at end of file |