| 6 | const { rules, parserPreset } = config; |
| 7 | |
| 8 | const lintMessage = async (message) => { |
| 9 | const parserOpts = parserPreset.parserOpts; |
| 10 | const m = message.replace(/^\s+/, "").trim(); |
| 11 | const result = await lint(m, rules, { parserOpts }); |
| 12 | |
| 13 | if (result.errors.length > 1) { |
| 14 | throw new Error("Commit test should only have one error message to validate against"); |
| 15 | } |
| 16 | |
| 17 | if (result.warnings.length > 1) { |
| 18 | throw new Error("Commit test should only have one warning message to validate against"); |
| 19 | } |
| 20 | |
| 21 | return result; |
| 22 | }; |
| 23 | |
| 24 | test("a valid commit message", async () => { |
| 25 | const result = await lintMessage("test: a valid angular commit"); |