Skip to content

Commit

Permalink
commitlint/plugins.test: add failing tests
Browse files Browse the repository at this point in the history
Add tests for reject-obvious-words rule.
  • Loading branch information
tehraninasab committed Aug 9, 2023
1 parent a096b47 commit 7c678a2
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions commitlint/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,68 @@ test("proper-issue-refs5", () => {
expect(properIssueRefs5.status).not.toBe(0);
});

test("reject-obvious-words1", () => {
let commitMsgWithObviousWordAfterColon = "foo: change";
let rejectObviousWords1 = runCommitLintOnMsg(
commitMsgWithObviousWordAfterColon
);
expect(rejectObviousWords1.status).not.toBe(0);
});

test("reject-obvious-words2", () => {
let commitMsgWithObviousWordAfterColon = "foo: change bla bla";
let rejectObviousWords2 = runCommitLintOnMsg(
commitMsgWithObviousWordAfterColon
);
expect(rejectObviousWords2.status).not.toBe(0);
});

test("reject-obvious-words3", () => {
let commitMsgWithObviousWordAfterColon = "foo: change bla bla\n\nBla blah.";
let rejectObviousWords3 = runCommitLintOnMsg(
commitMsgWithObviousWordAfterColon
);
expect(rejectObviousWords3.status).not.toBe(0);
});

test("reject-obvious-words4", () => {
let commitMsgWithoutObviousWordAfterColon = "foo: bla bla bla";
let rejectObviousWords4 = runCommitLintOnMsg(
commitMsgWithoutObviousWordAfterColon
);
expect(rejectObviousWords4.status).toBe(0);
});

test("reject-obvious-words5", () => {
// In general using `update` in commit message is a bad practice but there is
// exception in cases that the area refers to a file which is only modified when
// it needs updating and there's no need for further explanation of why it needs
// updating such as:
// README: update or Backend/servers.json: update

let commitMsgWithUpdateWordAfterColon = "foo: update";
let rejectObviousWords5 = runCommitLintOnMsg(
commitMsgWithUpdateWordAfterColon
);
expect(rejectObviousWords5.status).toBe(0);
});

test("reject-obvious-words6", () => {
let commitMsgWithUpdateWordAfterColon = "foo: update bla bla";
let rejectObviousWords6 = runCommitLintOnMsg(
commitMsgWithUpdateWordAfterColon
);
expect(rejectObviousWords6.status).not.toBe(0);
});

test("reject-obvious-words7", () => {
let commitMsgWithUpdateWordAfterColon = "foo: update bla bla\n\nBla blah.";
let rejectObviousWords7 = runCommitLintOnMsg(
commitMsgWithUpdateWordAfterColon
);
expect(rejectObviousWords7.status).toBe(0);
});

test("subject-lowercase1", () => {
let commitMsgWithUppercaseAfterColon = "foo: Bar baz";
let subjectLowerCase1 = runCommitLintOnMsg(
Expand Down

0 comments on commit 7c678a2

Please sign in to comment.