|
| 1 | +'use strict' |
| 2 | + |
| 3 | +const test = require('tap').test |
| 4 | +const Rule = require('../../lib/rules/line-after-title') |
| 5 | +const Commit = require('gitlint-parser-node') |
| 6 | +const Validator = require('../../') |
| 7 | + |
| 8 | +test('rule: line-after-title', (t) => { |
| 9 | + t.test('no blank line', (tt) => { |
| 10 | + tt.plan(7) |
| 11 | + const v = new Validator() |
| 12 | + const context = new Commit({ |
| 13 | + sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea' |
| 14 | + , author: { |
| 15 | + name: 'Evan Lucas' |
| 16 | + |
| 17 | + , date: '2016-04-12T19:42:23Z' |
| 18 | + } |
| 19 | + , message: 'test: fix something\nfhqwhgads' |
| 20 | + }, v) |
| 21 | + |
| 22 | + context.report = (opts) => { |
| 23 | + tt.pass('called report') |
| 24 | + tt.equal(opts.id, 'line-after-title', 'id') |
| 25 | + tt.equal(opts.message, 'blank line expected after title', 'message') |
| 26 | + tt.equal(opts.string, 'fhqwhgads', 'string') |
| 27 | + tt.equal(opts.line, 1, 'line') |
| 28 | + tt.equal(opts.column, 0, 'column') |
| 29 | + tt.equal(opts.level, 'fail', 'level') |
| 30 | + } |
| 31 | + |
| 32 | + Rule.validate(context) |
| 33 | + }) |
| 34 | + |
| 35 | + t.test('blank line', (tt) => { |
| 36 | + tt.plan(4) |
| 37 | + const v = new Validator() |
| 38 | + const context = new Commit({ |
| 39 | + sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea' |
| 40 | + , author: { |
| 41 | + name: 'Evan Lucas' |
| 42 | + |
| 43 | + , date: '2016-04-12T19:42:23Z' |
| 44 | + } |
| 45 | + , message: 'test: fix something\n\nfhqwhgads' |
| 46 | + }, v) |
| 47 | + |
| 48 | + context.report = (opts) => { |
| 49 | + tt.pass('called report') |
| 50 | + tt.equal(opts.id, 'line-after-title', 'id') |
| 51 | + tt.equal(opts.message, 'blank line after title', 'message') |
| 52 | + tt.equal(opts.level, 'pass', 'level') |
| 53 | + } |
| 54 | + |
| 55 | + Rule.validate(context) |
| 56 | + }) |
| 57 | + |
| 58 | + t.test('just one line', (tt) => { |
| 59 | + tt.plan(4) |
| 60 | + const v = new Validator() |
| 61 | + const context = new Commit({ |
| 62 | + sha: 'e7c077c610afa371430180fbd447bfef60ebc5ea' |
| 63 | + , author: { |
| 64 | + name: 'Evan Lucas' |
| 65 | + |
| 66 | + , date: '2016-04-12T19:42:23Z' |
| 67 | + } |
| 68 | + , message: 'test: fix something' |
| 69 | + }, v) |
| 70 | + |
| 71 | + context.report = (opts) => { |
| 72 | + tt.pass('called report') |
| 73 | + tt.equal(opts.id, 'line-after-title', 'id') |
| 74 | + tt.equal(opts.message, 'blank line after title', 'message') |
| 75 | + tt.equal(opts.level, 'pass', 'level') |
| 76 | + } |
| 77 | + |
| 78 | + Rule.validate(context) |
| 79 | + }) |
| 80 | + |
| 81 | + t.end() |
| 82 | +}) |
0 commit comments