Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit67bdfd7

Browse files
committed
test/update commit order
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent8ba4877 commit67bdfd7

File tree

2 files changed

+91
-43
lines changed

2 files changed

+91
-43
lines changed

‎src/utils/validateCommits.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export function validateCommitOrder(positions: string[]): boolean {
1313
current={level:0,step:0};
1414
return;
1515
}else{
16-
constlevelMatch=position.match(/^L([0-9]+)Q?$/);
17-
conststepMatch=position.match(/^L([0-9]+)S([0-9]+)[Q|A]?$/);
16+
constlevelMatch=position.match(/^L?([0-9]+)Q?$/);
17+
conststepMatch=position.match(/^L?([0-9]+)[S|\.]([0-9]+)[Q|A]?$/);
1818
if(levelMatch){
1919
// allows next level or step
2020
const[_,levelString]=levelMatch;

‎tests/commitOrder.test.ts

Lines changed: 89 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,95 @@
11
import{validateCommitOrder}from"../src/utils/validateCommits";
22

33
describe("commitOrder",()=>{
4-
it("should return true if order is valid",()=>{
5-
constpositions=["INIT","1","1.1","1.2","2","2.1"];
6-
constresult=validateCommitOrder(positions);
7-
expect(result).toBe(true);
4+
describe("#.# format",()=>{
5+
it("should return true if order is valid",()=>{
6+
constpositions=["INIT","1","1.1","1.2","2","2.1"];
7+
constresult=validateCommitOrder(positions);
8+
expect(result).toBe(true);
9+
});
10+
it("should return true if valid with duplicates",()=>{
11+
constpositions=[
12+
"INIT",
13+
"INIT",
14+
"1",
15+
"1",
16+
"1.1",
17+
"1.1",
18+
"1.2",
19+
"1.2",
20+
"2",
21+
"2",
22+
"2.1",
23+
"2.1",
24+
];
25+
constresult=validateCommitOrder(positions);
26+
expect(result).toBe(true);
27+
});
28+
it("should return false if INIT is out of order",()=>{
29+
constpositions=["INIT","1","1.1","1.2","INIT","2","2.1"];
30+
constresult=validateCommitOrder(positions);
31+
expect(result).toBe(false);
32+
});
33+
it("should return false if level after step is out of order",()=>{
34+
constpositions=["INIT","1","1.1","1.2","2.1","2"];
35+
constresult=validateCommitOrder(positions);
36+
expect(result).toBe(false);
37+
});
38+
it("should return false if level is out of order",()=>{
39+
constpositions=["INIT","1","L3","2"];
40+
constresult=validateCommitOrder(positions);
41+
expect(result).toBe(false);
42+
});
43+
it("should return false if step is out of order",()=>{
44+
constpositions=["INIT","1","1.1","1.3","1.2"];
45+
constresult=validateCommitOrder(positions);
46+
expect(result).toBe(false);
47+
});
848
});
9-
it("should return true if valid with duplicates",()=>{
10-
constpositions=[
11-
"INIT",
12-
"INIT",
13-
"1",
14-
"1",
15-
"1.1",
16-
"1.1",
17-
"1.2",
18-
"1.2",
19-
"2",
20-
"2",
21-
"2.1",
22-
"2.1",
23-
];
24-
constresult=validateCommitOrder(positions);
25-
expect(result).toBe(true);
26-
});
27-
it("should return false if INIT is out of order",()=>{
28-
constpositions=["INIT","1","1.1","1.2","INIT","2","2.1"];
29-
constresult=validateCommitOrder(positions);
30-
expect(result).toBe(false);
31-
});
32-
it("should return false if level after step is out of order",()=>{
33-
constpositions=["INIT","1","1.1","1.2","2.1","2"];
34-
constresult=validateCommitOrder(positions);
35-
expect(result).toBe(false);
36-
});
37-
it("should return false if level is out of order",()=>{
38-
constpositions=["INIT","1","L3","2"];
39-
constresult=validateCommitOrder(positions);
40-
expect(result).toBe(false);
41-
});
42-
it("should return false if step is out of order",()=>{
43-
constpositions=["INIT","1","1.1","1.3","1.2"];
44-
constresult=validateCommitOrder(positions);
45-
expect(result).toBe(false);
49+
//@deprecated
50+
describe("L#S# format",()=>{
51+
it("should return true if order is valid",()=>{
52+
constpositions=["INIT","L1","L1S1","L1S2","L2","L2S1"];
53+
constresult=validateCommitOrder(positions);
54+
expect(result).toBe(true);
55+
});
56+
it("should return true if valid with duplicates",()=>{
57+
constpositions=[
58+
"INIT",
59+
"INIT",
60+
"L1",
61+
"L1",
62+
"L1S1",
63+
"L1S1",
64+
"L1S2",
65+
"L1S2",
66+
"L2",
67+
"L2",
68+
"L2S1",
69+
"L2S1",
70+
];
71+
constresult=validateCommitOrder(positions);
72+
expect(result).toBe(true);
73+
});
74+
it("should return false if INIT is out of order",()=>{
75+
constpositions=["INIT","L1","L1S1","L1S2","INIT","L2","L2S1"];
76+
constresult=validateCommitOrder(positions);
77+
expect(result).toBe(false);
78+
});
79+
it("should return false if level after step is out of order",()=>{
80+
constpositions=["INIT","L1","L1S1","L1S2","L2S1","L2"];
81+
constresult=validateCommitOrder(positions);
82+
expect(result).toBe(false);
83+
});
84+
it("should return false if level is out of order",()=>{
85+
constpositions=["INIT","L1","L3","L2"];
86+
constresult=validateCommitOrder(positions);
87+
expect(result).toBe(false);
88+
});
89+
it("should return false if step is out of order",()=>{
90+
constpositions=["INIT","L1","L1S1","L1S3","L1S2"];
91+
constresult=validateCommitOrder(positions);
92+
expect(result).toBe(false);
93+
});
4694
});
4795
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp