-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests and bugfix for line-after-title (#29)
* add basic tests for line-after-title rule * fix line-after-title for commits without a body
- Loading branch information
Showing
2 changed files
with
83 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
'use strict' | ||
|
||
const test = require('tap').test | ||
const Rule = require('../../lib/rules/line-after-title') | ||
const Commit = require('gitlint-parser-node') | ||
const Validator = require('../../') | ||
|
||
test('rule: line-after-title', (t) => { | ||
t.test('no blank line', (tt) => { | ||
tt.plan(7) | ||
const v = new Validator() | ||
const context = new Commit({ | ||
sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea' | ||
, author: { | ||
name: 'Evan Lucas' | ||
, email: '[email protected]' | ||
, date: '2016-04-12T19:42:23Z' | ||
} | ||
, message: 'test: fix something\nfhqwhgads' | ||
}, v) | ||
|
||
context.report = (opts) => { | ||
tt.pass('called report') | ||
tt.equal(opts.id, 'line-after-title', 'id') | ||
tt.equal(opts.message, 'blank line expected after title', 'message') | ||
tt.equal(opts.string, 'fhqwhgads', 'string') | ||
tt.equal(opts.line, 1, 'line') | ||
tt.equal(opts.column, 0, 'column') | ||
tt.equal(opts.level, 'fail', 'level') | ||
} | ||
|
||
Rule.validate(context) | ||
}) | ||
|
||
t.test('blank line', (tt) => { | ||
tt.plan(4) | ||
const v = new Validator() | ||
const context = new Commit({ | ||
sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea' | ||
, author: { | ||
name: 'Evan Lucas' | ||
, email: '[email protected]' | ||
, date: '2016-04-12T19:42:23Z' | ||
} | ||
, message: 'test: fix something\n\nfhqwhgads' | ||
}, v) | ||
|
||
context.report = (opts) => { | ||
tt.pass('called report') | ||
tt.equal(opts.id, 'line-after-title', 'id') | ||
tt.equal(opts.message, 'blank line after title', 'message') | ||
tt.equal(opts.level, 'pass', 'level') | ||
} | ||
|
||
Rule.validate(context) | ||
}) | ||
|
||
t.test('just one line', (tt) => { | ||
tt.plan(4) | ||
const v = new Validator() | ||
const context = new Commit({ | ||
sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea' | ||
, author: { | ||
name: 'Evan Lucas' | ||
, email: '[email protected]' | ||
, date: '2016-04-12T19:42:23Z' | ||
} | ||
, message: 'test: fix something' | ||
}, v) | ||
|
||
context.report = (opts) => { | ||
tt.pass('called report') | ||
tt.equal(opts.id, 'line-after-title', 'id') | ||
tt.equal(opts.message, 'blank line after title', 'message') | ||
tt.equal(opts.level, 'pass', 'level') | ||
} | ||
|
||
Rule.validate(context) | ||
}) | ||
|
||
t.end() | ||
}) |