-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
107 lines (93 loc) · 2.09 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const assert = require('assert');
import { Prep } from './prep';
import { expect } from 'chai';
describe('arrayManip', () => {
it('should return 200', () => {
const v1 = [
[1, 2, 100],
[2, 5, 100],
[3, 4, 100],
];
assert.equal(200, Prep.arrayManip(5, v1));
});
it('should return 10', () => {
const v2 = [
[1, 5, 3],
[4, 8, 7],
[6, 9, 1],
];
assert.equal(10, Prep.arrayManip(10, v2));
});
it('should return 31', () => {
const v3 = [
[2, 6, 8],
[3, 5, 7],
[1, 8, 1],
[5, 9, 15],
];
assert.equal(31, Prep.arrayManip(10, v3));
});
it('should return 6314', () => {
const arr = [
[19, 28, 419],
[4, 23, 680],
[5, 6, 907],
[19, 33, 582],
[5, 9, 880],
[10, 13, 438],
[21, 39, 294],
[13, 18, 678],
[12, 26, 528],
[15, 30, 261],
[8, 9, 48],
[21, 23, 131],
[20, 21, 7],
[13, 40, 65],
[13, 23, 901],
[15, 15, 914],
[14, 35, 704],
[20, 39, 522],
[10, 18, 379],
[16, 27, 8],
[25, 40, 536],
[5, 9, 190],
[17, 20, 809],
[8, 20, 453],
[22, 37, 298],
[19, 37, 112],
[2, 5, 186],
[21, 29, 184],
[23, 30, 625],
[2, 8, 960],
];
assert.equal(6314, Prep.arrayManip(40, arr));
});
});
describe('triplet comparison', () => {
it('should return an array length of 2', () => {
const A = [17, 28, 30];
const B = [99, 16, 8];
assert.equal(2, Prep.compareTriplets(A, B).length);
});
it('should yield a tie', () => {
const A = [17, 28, 30];
const B = [99, 16, 8];
expect([2, 1]).to.eql(Prep.compareTriplets(A, B));
expect([1, 0]).to.not.eql(Prep.compareTriplets(A, B));
});
});
describe('stats - mean, median, mode', () => {
const a = '64630 11735 14216 99233 14470 4978 73429 38120 51135 67060';
it('should return a 3 length array', () => {
expect(Prep.statDay0(a).length).to.eql(3);
});
it('should return a mean of 43900.6', () => {
expect(Prep.statDay0(a)[0]).to.eql(43900.6);
});
it('should return a median of 44627.5', () => {
expect(Prep.statDay0(a)[1]).to.eql(44627.5);
});
it('should return a mode of 4978', () => {
expect(Prep.statDay0(a)[2]).to.eql(4978);
});
});