|
| 1 | +import test from 'ava'; |
| 2 | +import lint from '../_lint'; |
| 3 | + |
| 4 | +const config = { |
| 5 | + plugins: [ |
| 6 | + require('remark-lint'), |
| 7 | + require('../../rules/heading') |
| 8 | + ] |
| 9 | +}; |
| 10 | + |
| 11 | +test('heading - missing', async t => { |
| 12 | + const messages = await lint({config, filename: 'test/fixtures/heading/error0.md'}); |
| 13 | + t.deepEqual(messages, [ |
| 14 | + { |
| 15 | + ruleId: 'awesome/heading', |
| 16 | + message: 'Missing main list heading' |
| 17 | + } |
| 18 | + ]); |
| 19 | +}); |
| 20 | + |
| 21 | +test('heading - not in title case', async t => { |
| 22 | + const messages = await lint({config, filename: 'test/fixtures/heading/error1.md'}); |
| 23 | + t.deepEqual(messages, [ |
| 24 | + { |
| 25 | + ruleId: 'awesome/heading', |
| 26 | + message: 'Main heading must be in title case' |
| 27 | + } |
| 28 | + ]); |
| 29 | +}); |
| 30 | + |
| 31 | +test('heading - more than one heading', async t => { |
| 32 | + const messages = await lint({config, filename: 'test/fixtures/heading/error2.md'}); |
| 33 | + t.deepEqual(messages, [ |
| 34 | + { |
| 35 | + ruleId: 'awesome/heading', |
| 36 | + message: 'List can only have one heading' |
| 37 | + } |
| 38 | + ]); |
| 39 | +}); |
| 40 | + |
| 41 | +test('heading - depth is bigger than 1', async t => { |
| 42 | + const messages = await lint({config, filename: 'test/fixtures/heading/error3.md'}); |
| 43 | + t.deepEqual(messages, [ |
| 44 | + { |
| 45 | + ruleId: 'awesome/heading', |
| 46 | + message: 'Main list heading must be of depth 1' |
| 47 | + } |
| 48 | + ]); |
| 49 | +}); |
| 50 | + |
| 51 | +test('heading - success', async t => { |
| 52 | + const messages = await lint({config, filename: 'test/fixtures/heading/success0.md'}); |
| 53 | + t.deepEqual(messages, []); |
| 54 | +}); |
| 55 | + |
| 56 | +test('heading - success (with acronyms)', async t => { |
| 57 | + const messages = await lint({config, filename: 'test/fixtures/heading/success1.md'}); |
| 58 | + t.deepEqual(messages, []); |
| 59 | +}); |
0 commit comments