Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Feature/markdown as master #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Jun 24, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test/update commit order
Signed-off-by: shmck <[email protected]>
  • Loading branch information
ShMcK committed Jun 21, 2020
commit 67bdfd7e6291d7d41a0432680993b4a154c43263
4 changes: 2 additions & 2 deletions src/utils/validateCommits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export function validateCommitOrder(positions: string[]): boolean {
current = { level: 0, step: 0 };
return;
} else {
const levelMatch = position.match(/^L([0-9]+)Q?$/);
const stepMatch = position.match(/^L([0-9]+)S([0-9]+)[Q|A]?$/);
const levelMatch = position.match(/^L?([0-9]+)Q?$/);
const stepMatch = position.match(/^L?([0-9]+)[S|\.]([0-9]+)[Q|A]?$/);
if (levelMatch) {
// allows next level or step
const [_, levelString] = levelMatch;
Expand Down
130 changes: 89 additions & 41 deletions tests/commitOrder.test.ts
Original file line number Diff line number Diff line change
@@ -1,47 +1,95 @@
import { validateCommitOrder } from "../src/utils/validateCommits";

describe("commitOrder", () => {
it("should return true if order is valid", () => {
const positions = ["INIT", "1", "1.1", "1.2", "2", "2.1"];
const result = validateCommitOrder(positions);
expect(result).toBe(true);
describe("#.# format", () => {
it("should return true if order is valid", () => {
const positions = ["INIT", "1", "1.1", "1.2", "2", "2.1"];
const result = validateCommitOrder(positions);
expect(result).toBe(true);
});
it("should return true if valid with duplicates", () => {
const positions = [
"INIT",
"INIT",
"1",
"1",
"1.1",
"1.1",
"1.2",
"1.2",
"2",
"2",
"2.1",
"2.1",
];
const result = validateCommitOrder(positions);
expect(result).toBe(true);
});
it("should return false if INIT is out of order", () => {
const positions = ["INIT", "1", "1.1", "1.2", "INIT", "2", "2.1"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if level after step is out of order", () => {
const positions = ["INIT", "1", "1.1", "1.2", "2.1", "2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if level is out of order", () => {
const positions = ["INIT", "1", "L3", "2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if step is out of order", () => {
const positions = ["INIT", "1", "1.1", "1.3", "1.2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
});
it("should return true if valid with duplicates", () => {
const positions = [
"INIT",
"INIT",
"1",
"1",
"1.1",
"1.1",
"1.2",
"1.2",
"2",
"2",
"2.1",
"2.1",
];
const result = validateCommitOrder(positions);
expect(result).toBe(true);
});
it("should return false if INIT is out of order", () => {
const positions = ["INIT", "1", "1.1", "1.2", "INIT", "2", "2.1"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if level after step is out of order", () => {
const positions = ["INIT", "1", "1.1", "1.2", "2.1", "2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if level is out of order", () => {
const positions = ["INIT", "1", "L3", "2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
});
it("should return false if step is out of order", () => {
const positions = ["INIT", "1", "1.1", "1.3", "1.2"];
const result = validateCommitOrder(positions);
expect(result).toBe(false);
// @deprecated
describe("L#S# format", () => {
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);
});
});
});