|
1 | 1 | import { expect } from "chai"; |
2 | | -import { checkTitle } from "../src/validate"; |
| 2 | +import { allowedModules, allowedTypes, checkTitle } from "../src/validate"; |
3 | 3 |
|
4 | 4 | describe("validate", () => { |
5 | 5 | describe("checkTitle", () => { |
@@ -30,39 +30,63 @@ describe("validate", () => { |
30 | 30 | [ |
31 | 31 | [ |
32 | 32 | "[Refactor:RainbowGrades]", |
33 | | - "Invalid title format, must start with [<TYPE>:<MODULE>] and have space before description.", |
| 33 | + `Invalid PR title format. ` + |
| 34 | + `Your title should adhere to the format: [<TYPE>:<MODULE>] <SUBJECT> followed by a space before the description.\n` + |
| 35 | + `Where <TYPE> is one of: ${allowedTypes.join(", ")}\n` + |
| 36 | + `And <MODULE> is one of: ${allowedModules.join(", ")}\n` + |
| 37 | + `For detailed guidelines, refer to https://submitty.org/developer/getting_started/make_a_pull_request.`, |
34 | 38 | ], |
35 | 39 | [ |
36 | 40 | "[SYSADMINACTION][Refactor:Autograding] xxxx", |
37 | | - "Invalid title format, must start with [<TYPE>:<MODULE>] and have space before description.", |
| 41 | + `Invalid PR title format. ` + |
| 42 | + `Your title should adhere to the format: [<TYPE>:<MODULE>] <SUBJECT> followed by a space before the description.\n` + |
| 43 | + `Where <TYPE> is one of: ${allowedTypes.join(", ")}\n` + |
| 44 | + `And <MODULE> is one of: ${allowedModules.join(", ")}\n` + |
| 45 | + `For detailed guidelines, refer to https://submitty.org/developer/getting_started/make_a_pull_request.`, |
38 | 46 | ], |
39 | 47 | [ |
40 | 48 | "[SYSADMIN ACTION] [Refactor:Submission] test", |
41 | 49 | "There should not be a space following [SYSADMIN ACTION].", |
42 | 50 | ], |
43 | 51 | [ |
44 | 52 | "[SYSADMIN ACTION][Refactor:Autograding]foo", |
45 | | - "Invalid title format, must start with [SYSADMIN ACTION][<TYPE>:<MODULE>] and have space before description.", |
| 53 | + `Invalid PR title format. ` + |
| 54 | + `Your title must start with [SYSADMIN ACTION] and should adhere to the format: [<TYPE>:<MODULE>] <SUBJECT> followed by a space before the description.\n` + |
| 55 | + `Where <TYPE> is one of: ${allowedTypes.join(", ")}\n` + |
| 56 | + `And <MODULE> is one of: ${allowedModules.join(", ")}\n` + |
| 57 | + `For detailed guidelines, refer to https://submitty.org/developer/getting_started/make_a_pull_request.`, |
46 | 58 | ], |
47 | 59 | [ |
48 | 60 | "[SECURITY] [Refactor:Submission] test", |
49 | 61 | "There should not be a space following [SECURITY].", |
50 | 62 | ], |
51 | 63 | [ |
52 | 64 | "[SECURITY][Refactor:Autograding]foo", |
53 | | - "Invalid title format, must start with [SECURITY][<TYPE>:<MODULE>] and have space before description.", |
| 65 | + `Invalid PR title format. ` + |
| 66 | + `Your title must start with [SECURITY] and should adhere to the format: [<TYPE>:<MODULE>] <SUBJECT> followed by a space before the description.\n` + |
| 67 | + `Where <TYPE> is one of: ${allowedTypes.join(", ")}\n` + |
| 68 | + `And <MODULE> is one of: ${allowedModules.join(", ")}\n` + |
| 69 | + `For detailed guidelines, refer to https://submitty.org/developer/getting_started/make_a_pull_request.`, |
54 | 70 | ], |
55 | 71 | [ |
56 | 72 | "[Bugfix: Submission] xxx", |
57 | 73 | "Unexpected space between <TYPE> and <MODULE> (e.g. [<TYPE>: <MODULE>]), there should be no space (e.g. [<TYPE>:<MODULE>]).", |
58 | 74 | ], |
59 | 75 | [ |
60 | 76 | "[SYSADMIN ACTION][SECURITY][Refactor:Autograding]foo", |
61 | | - "Invalid title format, must start with [SYSADMIN ACTION][SECURITY][<TYPE>:<MODULE>] and have space before description.", |
| 77 | + `Invalid PR title format. ` + |
| 78 | + `Your title must start with [SYSADMIN ACTION] and should adhere to the format: [<TYPE>:<MODULE>] <SUBJECT> followed by a space before the description.\n` + |
| 79 | + `Where <TYPE> is one of: ${allowedTypes.join(", ")}\n` + |
| 80 | + `And <MODULE> is one of: ${allowedModules.join(", ")}\n` + |
| 81 | + `For detailed guidelines, refer to https://submitty.org/developer/getting_started/make_a_pull_request.`, |
62 | 82 | ], |
63 | 83 | [ |
64 | 84 | "[SECURITY][SYSADMIN ACTION][Refactor:Autograding] foo", |
65 | | - "Invalid title format, must start with [SECURITY][<TYPE>:<MODULE>] and have space before description.", |
| 85 | + `Invalid PR title format. ` + |
| 86 | + `Your title must start with [SECURITY] and should adhere to the format: [<TYPE>:<MODULE>] <SUBJECT> followed by a space before the description.\n` + |
| 87 | + `Where <TYPE> is one of: ${allowedTypes.join(", ")}\n` + |
| 88 | + `And <MODULE> is one of: ${allowedModules.join(", ")}\n` + |
| 89 | + `For detailed guidelines, refer to https://submitty.org/developer/getting_started/make_a_pull_request.`, |
66 | 90 | ], |
67 | 91 | ].forEach(([value, expectedException]) => { |
68 | 92 | it(`checkTitle should throw: ${value}`, () => { |
|
0 commit comments