-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.spec.ts
36 lines (30 loc) · 892 Bytes
/
index.spec.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
import meanMedianMode from ".";
describe("Mean, median, mode:", () => {
test("should return { mean: 3.25, median: 3.5, mode: [1, 4] }", () => {
const numArray = [1, 2, 3, 4, 5, 4, 6, 1];
const expected = {
mean: 3.25,
median: 3.5,
mode: [1, 4],
};
expect(meanMedianMode(numArray)).toEqual(expected);
});
test("should return { mean: 2.625, median: 2.5, mode: [0] }", () => {
const numArray = [0, 1, 2, 3, 0, 4, 5, 6];
const expected = {
mean: 2.625,
median: 2.5,
mode: [0],
};
expect(meanMedianMode(numArray)).toEqual(expected);
});
test("should return { mean: 2.875, median: 3, mode: [1, 3, 4] }", () => {
const numArray = [3, 5, 4, 4, 1, 1, 2, 3];
const expected = {
mean: 2.875,
median: 3,
mode: [1, 3, 4],
};
expect(meanMedianMode(numArray)).toEqual(expected);
});
});