1 | ;
|
2 | // *****************************************************************************
|
3 | // Copyright (C) 2017 TypeFox and others.
|
4 | //
|
5 | // This program and the accompanying materials are made available under the
|
6 | // terms of the Eclipse Public License v. 2.0 which is available at
|
7 | // http://www.eclipse.org/legal/epl-2.0.
|
8 | //
|
9 | // This Source Code may also be made available under the following Secondary
|
10 | // Licenses when the conditions for such availability set forth in the Eclipse
|
11 | // Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
12 | // with the GNU Classpath Exception which is available at
|
13 | // https://www.gnu.org/software/classpath/license.html.
|
14 | //
|
15 | // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
16 | // *****************************************************************************
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | const assert = require("assert");
|
19 | const types_1 = require("./types");
|
20 | describe('types', () => {
|
21 | describe('recursive-partial', () => {
|
22 | it('should handle nested arrays', () => {
|
23 | const myArr = [];
|
24 | const myFoo = {};
|
25 | if (myFoo.bar && myFoo.bar.arr) {
|
26 | const x = Array.from(new Set(myFoo.bar.arr));
|
27 | myArr.push(...x);
|
28 | }
|
29 | });
|
30 | });
|
31 | describe('Prioritizeable', () => {
|
32 | it('prioritizeAll #01', () => {
|
33 | const input = [-4, 4, -3, 3, -2, 2, -1, 1, 0, -0];
|
34 | return types_1.Prioritizeable.prioritizeAll(input, value => -value)
|
35 | .then(values => assert.deepStrictEqual([
|
36 | {
|
37 | priority: 4,
|
38 | value: -4
|
39 | },
|
40 | {
|
41 | priority: 3,
|
42 | value: -3
|
43 | }, {
|
44 | priority: 2,
|
45 | value: -2
|
46 | }, {
|
47 | priority: 1,
|
48 | value: -1
|
49 | }
|
50 | ], values));
|
51 | });
|
52 | it('prioritizeAll #02', () => {
|
53 | const input = [-4, 4, -3, 3, -2, 2, -1, 1, 0, -0].map(v => Promise.resolve(v));
|
54 | return types_1.Prioritizeable.prioritizeAll(input, value => -value)
|
55 | .then(values => assert.deepStrictEqual([
|
56 | {
|
57 | priority: 4,
|
58 | value: -4
|
59 | },
|
60 | {
|
61 | priority: 3,
|
62 | value: -3
|
63 | }, {
|
64 | priority: 2,
|
65 | value: -2
|
66 | }, {
|
67 | priority: 1,
|
68 | value: -1
|
69 | }
|
70 | ], values));
|
71 | });
|
72 | });
|
73 | });
|
74 | //# sourceMappingURL=types.spec.js.map |
\ | No newline at end of file |