-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommitOrder.test.ts
More file actions
47 lines (46 loc) · 1.48 KB
/
commitOrder.test.ts
File metadata and controls
47 lines (46 loc) · 1.48 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 { validateCommitOrder } from "../src/utils/validateCommits";
describe("commitOrder", () => {
it("should return true if order is valid", () => {
const positions = ["INIT", "L1", "L1S1", "L1S2", "L2", "L2S1"];
const result = validateCommitOrder(positions);
expect(result).toBe(true);
});
it("should return true if valid with duplicates", () => {
const positions = [
"INIT",
"INIT",
"L1",
"L1",
"L1S1",
"L1S1",
"L1S2",
"L1S2",
"L2",
"L2",
"L2S1",
"L2S1",
];
const result = validateCommitOrder(positions);
expect(result).toBe(true);
});
it("should return false if INIT is out of order", () => {
const positions = ["INIT", "L1", "L1S1", "L1S2", "INIT", "L2", "L2S1"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if level after step is out of order", () => {
const positions = ["INIT", "L1", "L1S1", "L1S2", "L2S1", "L2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if level is out of order", () => {
const positions = ["INIT", "L1", "L3", "L2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if step is out of order", () => {
const positions = ["INIT", "L1", "L1S1", "L1S3", "L1S2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
});