forked from dts-kominfo-rea2b/challenge-05-AlexFuad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test3.test.js
31 lines (27 loc) · 798 Bytes
/
test3.test.js
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
const { sorter, sortAscending, sortDescending, names } = require("./index");
describe("sorter", () => {
it("should be a function", () => {
expect(typeof sorter).toBe("function");
});
it("should return an array", () => {
expect(Array.isArray(sorter(names, sortAscending))).toBe(true);
});
it("should sort ascending with index when given callback is sortAscending", () => {
expect(sorter(names, sortAscending)).toEqual([
"1. Aisyah",
"2. Angel",
"3. Halo",
"4. Ketut",
"5. Nyoman",
]);
});
it("should sort descending with index when given callback is sortAscending", () => {
expect(sorter(names, sortDescending)).toEqual([
"1. Nyoman",
"2. Ketut",
"3. Halo",
"4. Angel",
"5. Aisyah",
]);
});
});