From 7af8d9a8b313bb895ef803cb9db2d5bd20456df2 Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 1 Feb 2020 01:45:06 +0100 Subject: [PATCH 1/2] test: add simple generic config validations --- .../__snapshots__/index.test.js.snap | 22 ++ .../config-angular-type-enum/index.test.js | 27 +++ .../config-angular-type-enum/package.json | 9 +- .../__snapshots__/index.test.js.snap | 204 ++++++++++++++++++ @commitlint/config-angular/index.test.js | 27 +++ @commitlint/config-angular/package.json | 9 +- .../__snapshots__/index.test.js.snap | 204 ++++++++++++++++++ @commitlint/config-conventional/index.test.js | 27 +++ @commitlint/config-conventional/package.json | 9 +- jest.config.js | 5 +- 10 files changed, 539 insertions(+), 4 deletions(-) create mode 100644 @commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap create mode 100644 @commitlint/config-angular-type-enum/index.test.js create mode 100644 @commitlint/config-angular/__snapshots__/index.test.js.snap create mode 100644 @commitlint/config-angular/index.test.js create mode 100644 @commitlint/config-conventional/__snapshots__/index.test.js.snap create mode 100644 @commitlint/config-conventional/index.test.js diff --git a/@commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap b/@commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..858fabe659 --- /dev/null +++ b/@commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap @@ -0,0 +1,22 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`rules type-enum empty 1`] = ` +Array [ + false, + "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", +] +`; + +exports[`rules type-enum filled 1`] = ` +Array [ + false, + "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", +] +`; + +exports[`rules type-enum simple 1`] = ` +Array [ + false, + "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", +] +`; diff --git a/@commitlint/config-angular-type-enum/index.test.js b/@commitlint/config-angular-type-enum/index.test.js new file mode 100644 index 0000000000..7baf4cca16 --- /dev/null +++ b/@commitlint/config-angular-type-enum/index.test.js @@ -0,0 +1,27 @@ +import config from '.'; +import rules from '@commitlint/rules'; +import parse from '@commitlint/parse'; + +const messages = Object.entries({ + simple: 'test: subject', + empty: 'test: subject\nbody', + filled: 'test: subject\nBREAKING CHANGE: something important' +}); +const configRules = Object.entries(config.rules); + +it('should have correct structure', () => { + expect(config).toMatchObject({ + rules: expect.any(Object) + }); +}); + +describe('rules', () => { + describe.each(configRules)('%s', (name, options) => { + const severity = options.unshift(); + it.each(messages)('%s', async (type, message) => { + expect( + rules[name](await parse(message), severity, options) + ).toMatchSnapshot(); + }); + }); +}); diff --git a/@commitlint/config-angular-type-enum/package.json b/@commitlint/config-angular-type-enum/package.json index 65cc3b0a0e..6261921321 100644 --- a/@commitlint/config-angular-type-enum/package.json +++ b/@commitlint/config-angular-type-enum/package.json @@ -28,7 +28,14 @@ "url": "https://github.com/conventional-changelog/commitlint/issues" }, "homepage": "https://github.com/conventional-changelog/commitlint#readme", + "babel": { + "presets": [ + "babel-preset-commitlint" + ] + }, "devDependencies": { - "@commitlint/utils": "^8.3.4" + "@commitlint/utils": "^8.3.4", + "@commitlint/rules": "^8.3.4", + "@commitlint/parse": "^8.3.4" } } diff --git a/@commitlint/config-angular/__snapshots__/index.test.js.snap b/@commitlint/config-angular/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..1a474b52a1 --- /dev/null +++ b/@commitlint/config-angular/__snapshots__/index.test.js.snap @@ -0,0 +1,204 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`rules body-leading-blank empty 1`] = ` +Array [ + false, + "body must have leading blank line", +] +`; + +exports[`rules body-leading-blank filled 1`] = ` +Array [ + true, +] +`; + +exports[`rules body-leading-blank simple 1`] = ` +Array [ + true, +] +`; + +exports[`rules footer-leading-blank empty 1`] = ` +Array [ + true, +] +`; + +exports[`rules footer-leading-blank filled 1`] = ` +Array [ + false, + "footer must have leading blank line", +] +`; + +exports[`rules footer-leading-blank simple 1`] = ` +Array [ + true, +] +`; + +exports[`rules header-max-length empty 1`] = ` +Array [ + false, + "header must not be longer than 2,always,72 characters, current length is 13", +] +`; + +exports[`rules header-max-length filled 1`] = ` +Array [ + false, + "header must not be longer than 2,always,72 characters, current length is 13", +] +`; + +exports[`rules header-max-length simple 1`] = ` +Array [ + false, + "header must not be longer than 2,always,72 characters, current length is 13", +] +`; + +exports[`rules scope-case empty 1`] = ` +Array [ + true, +] +`; + +exports[`rules scope-case filled 1`] = ` +Array [ + true, +] +`; + +exports[`rules scope-case simple 1`] = ` +Array [ + true, +] +`; + +exports[`rules subject-case empty 1`] = ` +Array [ + true, + "subject must be , never, ", +] +`; + +exports[`rules subject-case filled 1`] = ` +Array [ + true, + "subject must be , never, ", +] +`; + +exports[`rules subject-case simple 1`] = ` +Array [ + true, + "subject must be , never, ", +] +`; + +exports[`rules subject-empty empty 1`] = ` +Array [ + false, + "subject must be empty", +] +`; + +exports[`rules subject-empty filled 1`] = ` +Array [ + false, + "subject must be empty", +] +`; + +exports[`rules subject-empty simple 1`] = ` +Array [ + false, + "subject must be empty", +] +`; + +exports[`rules subject-full-stop empty 1`] = ` +Array [ + false, + "subject must end with full stop", +] +`; + +exports[`rules subject-full-stop filled 1`] = ` +Array [ + false, + "subject must end with full stop", +] +`; + +exports[`rules subject-full-stop simple 1`] = ` +Array [ + false, + "subject must end with full stop", +] +`; + +exports[`rules type-case empty 1`] = ` +Array [ + true, + "type must be , always, lower-case", +] +`; + +exports[`rules type-case filled 1`] = ` +Array [ + true, + "type must be , always, lower-case", +] +`; + +exports[`rules type-case simple 1`] = ` +Array [ + true, + "type must be , always, lower-case", +] +`; + +exports[`rules type-empty empty 1`] = ` +Array [ + false, + "type must be empty", +] +`; + +exports[`rules type-empty filled 1`] = ` +Array [ + false, + "type must be empty", +] +`; + +exports[`rules type-empty simple 1`] = ` +Array [ + false, + "type must be empty", +] +`; + +exports[`rules type-enum empty 1`] = ` +Array [ + false, + "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", +] +`; + +exports[`rules type-enum filled 1`] = ` +Array [ + false, + "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", +] +`; + +exports[`rules type-enum simple 1`] = ` +Array [ + false, + "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", +] +`; diff --git a/@commitlint/config-angular/index.test.js b/@commitlint/config-angular/index.test.js new file mode 100644 index 0000000000..7baf4cca16 --- /dev/null +++ b/@commitlint/config-angular/index.test.js @@ -0,0 +1,27 @@ +import config from '.'; +import rules from '@commitlint/rules'; +import parse from '@commitlint/parse'; + +const messages = Object.entries({ + simple: 'test: subject', + empty: 'test: subject\nbody', + filled: 'test: subject\nBREAKING CHANGE: something important' +}); +const configRules = Object.entries(config.rules); + +it('should have correct structure', () => { + expect(config).toMatchObject({ + rules: expect.any(Object) + }); +}); + +describe('rules', () => { + describe.each(configRules)('%s', (name, options) => { + const severity = options.unshift(); + it.each(messages)('%s', async (type, message) => { + expect( + rules[name](await parse(message), severity, options) + ).toMatchSnapshot(); + }); + }); +}); diff --git a/@commitlint/config-angular/package.json b/@commitlint/config-angular/package.json index 0f17a56526..9c5a0cfb89 100644 --- a/@commitlint/config-angular/package.json +++ b/@commitlint/config-angular/package.json @@ -28,8 +28,15 @@ "url": "https://github.com/conventional-changelog/commitlint/issues" }, "homepage": "https://github.com/conventional-changelog/commitlint#readme", + "babel": { + "presets": [ + "babel-preset-commitlint" + ] + }, "devDependencies": { - "@commitlint/utils": "^8.3.4" + "@commitlint/utils": "^8.3.4", + "@commitlint/rules": "^8.3.4", + "@commitlint/parse": "^8.3.4" }, "dependencies": { "@commitlint/config-angular-type-enum": "^8.3.4" diff --git a/@commitlint/config-conventional/__snapshots__/index.test.js.snap b/@commitlint/config-conventional/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..e4ef01c228 --- /dev/null +++ b/@commitlint/config-conventional/__snapshots__/index.test.js.snap @@ -0,0 +1,204 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`rules body-leading-blank empty 1`] = ` +Array [ + false, + "body must have leading blank line", +] +`; + +exports[`rules body-leading-blank filled 1`] = ` +Array [ + true, +] +`; + +exports[`rules body-leading-blank simple 1`] = ` +Array [ + true, +] +`; + +exports[`rules footer-leading-blank empty 1`] = ` +Array [ + true, +] +`; + +exports[`rules footer-leading-blank filled 1`] = ` +Array [ + false, + "footer must have leading blank line", +] +`; + +exports[`rules footer-leading-blank simple 1`] = ` +Array [ + true, +] +`; + +exports[`rules header-max-length empty 1`] = ` +Array [ + false, + "header must not be longer than 2,always,72 characters, current length is 13", +] +`; + +exports[`rules header-max-length filled 1`] = ` +Array [ + false, + "header must not be longer than 2,always,72 characters, current length is 13", +] +`; + +exports[`rules header-max-length simple 1`] = ` +Array [ + false, + "header must not be longer than 2,always,72 characters, current length is 13", +] +`; + +exports[`rules scope-case empty 1`] = ` +Array [ + true, +] +`; + +exports[`rules scope-case filled 1`] = ` +Array [ + true, +] +`; + +exports[`rules scope-case simple 1`] = ` +Array [ + true, +] +`; + +exports[`rules subject-case empty 1`] = ` +Array [ + true, + "subject must be , never, ", +] +`; + +exports[`rules subject-case filled 1`] = ` +Array [ + true, + "subject must be , never, ", +] +`; + +exports[`rules subject-case simple 1`] = ` +Array [ + true, + "subject must be , never, ", +] +`; + +exports[`rules subject-empty empty 1`] = ` +Array [ + false, + "subject must be empty", +] +`; + +exports[`rules subject-empty filled 1`] = ` +Array [ + false, + "subject must be empty", +] +`; + +exports[`rules subject-empty simple 1`] = ` +Array [ + false, + "subject must be empty", +] +`; + +exports[`rules subject-full-stop empty 1`] = ` +Array [ + false, + "subject must end with full stop", +] +`; + +exports[`rules subject-full-stop filled 1`] = ` +Array [ + false, + "subject must end with full stop", +] +`; + +exports[`rules subject-full-stop simple 1`] = ` +Array [ + false, + "subject must end with full stop", +] +`; + +exports[`rules type-case empty 1`] = ` +Array [ + true, + "type must be , always, lower-case", +] +`; + +exports[`rules type-case filled 1`] = ` +Array [ + true, + "type must be , always, lower-case", +] +`; + +exports[`rules type-case simple 1`] = ` +Array [ + true, + "type must be , always, lower-case", +] +`; + +exports[`rules type-empty empty 1`] = ` +Array [ + false, + "type must be empty", +] +`; + +exports[`rules type-empty filled 1`] = ` +Array [ + false, + "type must be empty", +] +`; + +exports[`rules type-empty simple 1`] = ` +Array [ + false, + "type must be empty", +] +`; + +exports[`rules type-enum empty 1`] = ` +Array [ + false, + "type must be one of [2, always, build,chore,ci,docs,feat,fix,improvement,perf,refactor,revert,style,test]", +] +`; + +exports[`rules type-enum filled 1`] = ` +Array [ + false, + "type must be one of [2, always, build,chore,ci,docs,feat,fix,improvement,perf,refactor,revert,style,test]", +] +`; + +exports[`rules type-enum simple 1`] = ` +Array [ + false, + "type must be one of [2, always, build,chore,ci,docs,feat,fix,improvement,perf,refactor,revert,style,test]", +] +`; diff --git a/@commitlint/config-conventional/index.test.js b/@commitlint/config-conventional/index.test.js new file mode 100644 index 0000000000..7baf4cca16 --- /dev/null +++ b/@commitlint/config-conventional/index.test.js @@ -0,0 +1,27 @@ +import config from '.'; +import rules from '@commitlint/rules'; +import parse from '@commitlint/parse'; + +const messages = Object.entries({ + simple: 'test: subject', + empty: 'test: subject\nbody', + filled: 'test: subject\nBREAKING CHANGE: something important' +}); +const configRules = Object.entries(config.rules); + +it('should have correct structure', () => { + expect(config).toMatchObject({ + rules: expect.any(Object) + }); +}); + +describe('rules', () => { + describe.each(configRules)('%s', (name, options) => { + const severity = options.unshift(); + it.each(messages)('%s', async (type, message) => { + expect( + rules[name](await parse(message), severity, options) + ).toMatchSnapshot(); + }); + }); +}); diff --git a/@commitlint/config-conventional/package.json b/@commitlint/config-conventional/package.json index d5e029c1e9..c22531eafc 100644 --- a/@commitlint/config-conventional/package.json +++ b/@commitlint/config-conventional/package.json @@ -31,8 +31,15 @@ "url": "https://github.com/conventional-changelog/commitlint/issues" }, "homepage": "https://github.com/conventional-changelog/commitlint#readme", + "babel": { + "presets": [ + "babel-preset-commitlint" + ] + }, "devDependencies": { - "@commitlint/utils": "^8.3.4" + "@commitlint/utils": "^8.3.4", + "@commitlint/rules": "^8.3.4", + "@commitlint/parse": "^8.3.4" }, "dependencies": { "conventional-changelog-conventionalcommits": "4.2.1" diff --git a/jest.config.js b/jest.config.js index c410a745b3..31455b2b4b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -8,6 +8,9 @@ module.exports = { '**/@commitlint/read/src/*.test.js?(x)', '**/@commitlint/travis-cli/src/*.test.js?(x)', '**/@commitlint/cli/src/*.test.js?(x)', - '**/@commitlint/prompt-cli/*.test.js?(x)' + '**/@commitlint/prompt-cli/*.test.js?(x)', + '**/@commitlint/config-angular/*.test.js?(x)', + '**/@commitlint/config-angular-type-enum/*.test.js?(x)', + '**/@commitlint/config-conventional/*.test.js?(x)' ] }; From 7f7e34d2b469802e2ff24f7575cd2294c1aeafdc Mon Sep 17 00:00:00 2001 From: Armano Date: Sat, 1 Feb 2020 02:06:23 +0100 Subject: [PATCH 2/2] test: update tests --- .../__snapshots__/index.test.js.snap | 12 ++-- .../config-angular-type-enum/index.test.js | 3 +- .../__snapshots__/index.test.js.snap | 72 +++++++++---------- @commitlint/config-angular/index.test.js | 3 +- .../__snapshots__/index.test.js.snap | 72 +++++++++---------- @commitlint/config-conventional/index.test.js | 3 +- 6 files changed, 81 insertions(+), 84 deletions(-) diff --git a/@commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap b/@commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap index 858fabe659..d79baebf21 100644 --- a/@commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap +++ b/@commitlint/config-angular-type-enum/__snapshots__/index.test.js.snap @@ -2,21 +2,21 @@ exports[`rules type-enum empty 1`] = ` Array [ - false, - "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", + true, + "type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style, test]", ] `; exports[`rules type-enum filled 1`] = ` Array [ - false, - "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", + true, + "type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style, test]", ] `; exports[`rules type-enum simple 1`] = ` Array [ - false, - "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", + true, + "type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style, test]", ] `; diff --git a/@commitlint/config-angular-type-enum/index.test.js b/@commitlint/config-angular-type-enum/index.test.js index 7baf4cca16..021d1328f0 100644 --- a/@commitlint/config-angular-type-enum/index.test.js +++ b/@commitlint/config-angular-type-enum/index.test.js @@ -17,10 +17,9 @@ it('should have correct structure', () => { describe('rules', () => { describe.each(configRules)('%s', (name, options) => { - const severity = options.unshift(); it.each(messages)('%s', async (type, message) => { expect( - rules[name](await parse(message), severity, options) + rules[name](await parse(message), ...options.slice(1)) ).toMatchSnapshot(); }); }); diff --git a/@commitlint/config-angular/__snapshots__/index.test.js.snap b/@commitlint/config-angular/__snapshots__/index.test.js.snap index 1a474b52a1..2f0cff0cc1 100644 --- a/@commitlint/config-angular/__snapshots__/index.test.js.snap +++ b/@commitlint/config-angular/__snapshots__/index.test.js.snap @@ -40,22 +40,22 @@ Array [ exports[`rules header-max-length empty 1`] = ` Array [ - false, - "header must not be longer than 2,always,72 characters, current length is 13", + true, + "header must not be longer than 72 characters, current length is 13", ] `; exports[`rules header-max-length filled 1`] = ` Array [ - false, - "header must not be longer than 2,always,72 characters, current length is 13", + true, + "header must not be longer than 72 characters, current length is 13", ] `; exports[`rules header-max-length simple 1`] = ` Array [ - false, - "header must not be longer than 2,always,72 characters, current length is 13", + true, + "header must not be longer than 72 characters, current length is 13", ] `; @@ -80,125 +80,125 @@ Array [ exports[`rules subject-case empty 1`] = ` Array [ true, - "subject must be , never, ", + "subject must not be sentence-case, start-case, pascal-case, upper-case", ] `; exports[`rules subject-case filled 1`] = ` Array [ true, - "subject must be , never, ", + "subject must not be sentence-case, start-case, pascal-case, upper-case", ] `; exports[`rules subject-case simple 1`] = ` Array [ true, - "subject must be , never, ", + "subject must not be sentence-case, start-case, pascal-case, upper-case", ] `; exports[`rules subject-empty empty 1`] = ` Array [ - false, - "subject must be empty", + true, + "subject may not be empty", ] `; exports[`rules subject-empty filled 1`] = ` Array [ - false, - "subject must be empty", + true, + "subject may not be empty", ] `; exports[`rules subject-empty simple 1`] = ` Array [ - false, - "subject must be empty", + true, + "subject may not be empty", ] `; exports[`rules subject-full-stop empty 1`] = ` Array [ - false, - "subject must end with full stop", + true, + "subject may not end with full stop", ] `; exports[`rules subject-full-stop filled 1`] = ` Array [ - false, - "subject must end with full stop", + true, + "subject may not end with full stop", ] `; exports[`rules subject-full-stop simple 1`] = ` Array [ - false, - "subject must end with full stop", + true, + "subject may not end with full stop", ] `; exports[`rules type-case empty 1`] = ` Array [ true, - "type must be , always, lower-case", + "type must be lower-case", ] `; exports[`rules type-case filled 1`] = ` Array [ true, - "type must be , always, lower-case", + "type must be lower-case", ] `; exports[`rules type-case simple 1`] = ` Array [ true, - "type must be , always, lower-case", + "type must be lower-case", ] `; exports[`rules type-empty empty 1`] = ` Array [ - false, - "type must be empty", + true, + "type may not be empty", ] `; exports[`rules type-empty filled 1`] = ` Array [ - false, - "type must be empty", + true, + "type may not be empty", ] `; exports[`rules type-empty simple 1`] = ` Array [ - false, - "type must be empty", + true, + "type may not be empty", ] `; exports[`rules type-enum empty 1`] = ` Array [ - false, - "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", + true, + "type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style, test]", ] `; exports[`rules type-enum filled 1`] = ` Array [ - false, - "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", + true, + "type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style, test]", ] `; exports[`rules type-enum simple 1`] = ` Array [ - false, - "type must be one of [2, always, build,ci,docs,feat,fix,perf,refactor,revert,style,test]", + true, + "type must be one of [build, ci, docs, feat, fix, perf, refactor, revert, style, test]", ] `; diff --git a/@commitlint/config-angular/index.test.js b/@commitlint/config-angular/index.test.js index 7baf4cca16..021d1328f0 100644 --- a/@commitlint/config-angular/index.test.js +++ b/@commitlint/config-angular/index.test.js @@ -17,10 +17,9 @@ it('should have correct structure', () => { describe('rules', () => { describe.each(configRules)('%s', (name, options) => { - const severity = options.unshift(); it.each(messages)('%s', async (type, message) => { expect( - rules[name](await parse(message), severity, options) + rules[name](await parse(message), ...options.slice(1)) ).toMatchSnapshot(); }); }); diff --git a/@commitlint/config-conventional/__snapshots__/index.test.js.snap b/@commitlint/config-conventional/__snapshots__/index.test.js.snap index e4ef01c228..3fc93b31ec 100644 --- a/@commitlint/config-conventional/__snapshots__/index.test.js.snap +++ b/@commitlint/config-conventional/__snapshots__/index.test.js.snap @@ -40,22 +40,22 @@ Array [ exports[`rules header-max-length empty 1`] = ` Array [ - false, - "header must not be longer than 2,always,72 characters, current length is 13", + true, + "header must not be longer than 72 characters, current length is 13", ] `; exports[`rules header-max-length filled 1`] = ` Array [ - false, - "header must not be longer than 2,always,72 characters, current length is 13", + true, + "header must not be longer than 72 characters, current length is 13", ] `; exports[`rules header-max-length simple 1`] = ` Array [ - false, - "header must not be longer than 2,always,72 characters, current length is 13", + true, + "header must not be longer than 72 characters, current length is 13", ] `; @@ -80,125 +80,125 @@ Array [ exports[`rules subject-case empty 1`] = ` Array [ true, - "subject must be , never, ", + "subject must not be sentence-case, start-case, pascal-case, upper-case", ] `; exports[`rules subject-case filled 1`] = ` Array [ true, - "subject must be , never, ", + "subject must not be sentence-case, start-case, pascal-case, upper-case", ] `; exports[`rules subject-case simple 1`] = ` Array [ true, - "subject must be , never, ", + "subject must not be sentence-case, start-case, pascal-case, upper-case", ] `; exports[`rules subject-empty empty 1`] = ` Array [ - false, - "subject must be empty", + true, + "subject may not be empty", ] `; exports[`rules subject-empty filled 1`] = ` Array [ - false, - "subject must be empty", + true, + "subject may not be empty", ] `; exports[`rules subject-empty simple 1`] = ` Array [ - false, - "subject must be empty", + true, + "subject may not be empty", ] `; exports[`rules subject-full-stop empty 1`] = ` Array [ - false, - "subject must end with full stop", + true, + "subject may not end with full stop", ] `; exports[`rules subject-full-stop filled 1`] = ` Array [ - false, - "subject must end with full stop", + true, + "subject may not end with full stop", ] `; exports[`rules subject-full-stop simple 1`] = ` Array [ - false, - "subject must end with full stop", + true, + "subject may not end with full stop", ] `; exports[`rules type-case empty 1`] = ` Array [ true, - "type must be , always, lower-case", + "type must be lower-case", ] `; exports[`rules type-case filled 1`] = ` Array [ true, - "type must be , always, lower-case", + "type must be lower-case", ] `; exports[`rules type-case simple 1`] = ` Array [ true, - "type must be , always, lower-case", + "type must be lower-case", ] `; exports[`rules type-empty empty 1`] = ` Array [ - false, - "type must be empty", + true, + "type may not be empty", ] `; exports[`rules type-empty filled 1`] = ` Array [ - false, - "type must be empty", + true, + "type may not be empty", ] `; exports[`rules type-empty simple 1`] = ` Array [ - false, - "type must be empty", + true, + "type may not be empty", ] `; exports[`rules type-enum empty 1`] = ` Array [ - false, - "type must be one of [2, always, build,chore,ci,docs,feat,fix,improvement,perf,refactor,revert,style,test]", + true, + "type must be one of [build, chore, ci, docs, feat, fix, improvement, perf, refactor, revert, style, test]", ] `; exports[`rules type-enum filled 1`] = ` Array [ - false, - "type must be one of [2, always, build,chore,ci,docs,feat,fix,improvement,perf,refactor,revert,style,test]", + true, + "type must be one of [build, chore, ci, docs, feat, fix, improvement, perf, refactor, revert, style, test]", ] `; exports[`rules type-enum simple 1`] = ` Array [ - false, - "type must be one of [2, always, build,chore,ci,docs,feat,fix,improvement,perf,refactor,revert,style,test]", + true, + "type must be one of [build, chore, ci, docs, feat, fix, improvement, perf, refactor, revert, style, test]", ] `; diff --git a/@commitlint/config-conventional/index.test.js b/@commitlint/config-conventional/index.test.js index 7baf4cca16..021d1328f0 100644 --- a/@commitlint/config-conventional/index.test.js +++ b/@commitlint/config-conventional/index.test.js @@ -17,10 +17,9 @@ it('should have correct structure', () => { describe('rules', () => { describe.each(configRules)('%s', (name, options) => { - const severity = options.unshift(); it.each(messages)('%s', async (type, message) => { expect( - rules[name](await parse(message), severity, options) + rules[name](await parse(message), ...options.slice(1)) ).toMatchSnapshot(); }); });