Skip to content

Commit 7c678a2

Browse files
committed
commitlint/plugins.test: add failing tests
Add tests for reject-obvious-words rule.
1 parent a096b47 commit 7c678a2

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

commitlint/plugins.test.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -846,6 +846,68 @@ test("proper-issue-refs5", () => {
846846
expect(properIssueRefs5.status).not.toBe(0);
847847
});
848848

849+
test("reject-obvious-words1", () => {
850+
let commitMsgWithObviousWordAfterColon = "foo: change";
851+
let rejectObviousWords1 = runCommitLintOnMsg(
852+
commitMsgWithObviousWordAfterColon
853+
);
854+
expect(rejectObviousWords1.status).not.toBe(0);
855+
});
856+
857+
test("reject-obvious-words2", () => {
858+
let commitMsgWithObviousWordAfterColon = "foo: change bla bla";
859+
let rejectObviousWords2 = runCommitLintOnMsg(
860+
commitMsgWithObviousWordAfterColon
861+
);
862+
expect(rejectObviousWords2.status).not.toBe(0);
863+
});
864+
865+
test("reject-obvious-words3", () => {
866+
let commitMsgWithObviousWordAfterColon = "foo: change bla bla\n\nBla blah.";
867+
let rejectObviousWords3 = runCommitLintOnMsg(
868+
commitMsgWithObviousWordAfterColon
869+
);
870+
expect(rejectObviousWords3.status).not.toBe(0);
871+
});
872+
873+
test("reject-obvious-words4", () => {
874+
let commitMsgWithoutObviousWordAfterColon = "foo: bla bla bla";
875+
let rejectObviousWords4 = runCommitLintOnMsg(
876+
commitMsgWithoutObviousWordAfterColon
877+
);
878+
expect(rejectObviousWords4.status).toBe(0);
879+
});
880+
881+
test("reject-obvious-words5", () => {
882+
// In general using `update` in commit message is a bad practice but there is
883+
// exception in cases that the area refers to a file which is only modified when
884+
// it needs updating and there's no need for further explanation of why it needs
885+
// updating such as:
886+
// README: update or Backend/servers.json: update
887+
888+
let commitMsgWithUpdateWordAfterColon = "foo: update";
889+
let rejectObviousWords5 = runCommitLintOnMsg(
890+
commitMsgWithUpdateWordAfterColon
891+
);
892+
expect(rejectObviousWords5.status).toBe(0);
893+
});
894+
895+
test("reject-obvious-words6", () => {
896+
let commitMsgWithUpdateWordAfterColon = "foo: update bla bla";
897+
let rejectObviousWords6 = runCommitLintOnMsg(
898+
commitMsgWithUpdateWordAfterColon
899+
);
900+
expect(rejectObviousWords6.status).not.toBe(0);
901+
});
902+
903+
test("reject-obvious-words7", () => {
904+
let commitMsgWithUpdateWordAfterColon = "foo: update bla bla\n\nBla blah.";
905+
let rejectObviousWords7 = runCommitLintOnMsg(
906+
commitMsgWithUpdateWordAfterColon
907+
);
908+
expect(rejectObviousWords7.status).toBe(0);
909+
});
910+
849911
test("subject-lowercase1", () => {
850912
let commitMsgWithUppercaseAfterColon = "foo: Bar baz";
851913
let subjectLowerCase1 = runCommitLintOnMsg(

0 commit comments

Comments
 (0)