-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.test.js
More file actions
47 lines (44 loc) · 1.07 KB
/
main.test.js
File metadata and controls
47 lines (44 loc) · 1.07 KB
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
import { test, expect, describe } from "vitest";
import { whoAteAllThePies } from "./main.js";
describe("tests should pass if inputs are valid", () => {
const validArray = [
[10, 2, 5, false],
[10, 6, 2, false],
[50, 2, 25, false],
[50, 6, 9, true],
[10, 2.0, 5, false],
];
test.each(validArray)(
"Testing valid values %i, %i",
(bootcampers, slices, pies, canChrisFaisalNadeemComeToo) => {
const outcome = whoAteAllThePies(bootcampers, slices);
const expected = [pies, canChrisFaisalNadeemComeToo];
expect(outcome).toStrictEqual(expected);
}
);
});
describe("should throw error if invalid input or inputs", () => {
const invalidArray = [
[9, 1],
[9, 2],
[10, 1],
[9, 6],
[9, 7],
[10, 7],
[50, 1],
[51, 1],
[51, 2],
[50, 7],
[51, 6],
[51, 7],
// ["10", 2],
// [10, "ten"],
// [10.2, 2],
];
test.each(invalidArray)(
"Testing invalid values %i %i",
(bootcampers, slices) => {
expect(() => whoAteAllThePies(bootcampers, slices)).toThrowError();
}
);
});