|
| 1 | +import test from 'ava'; |
| 2 | +import parse from '@commitlint/parse'; |
| 3 | +import check from './footer-max-line-length'; |
| 4 | + |
| 5 | +const short = 'BREAKING CHANGE: a'; |
| 6 | +const long = 'BREAKING CHANGE: ab'; |
| 7 | + |
| 8 | +const value = short.length; |
| 9 | + |
| 10 | +const messages = { |
| 11 | + simple: 'test: subject', |
| 12 | + empty: 'test: subject\nbody', |
| 13 | + short: `test: subject\n${short}`, |
| 14 | + long: `test: subject\n${long}`, |
| 15 | + shortMultipleLines: `test:subject\n${short}\n${short}\n${short}`, |
| 16 | + longMultipleLines: `test:subject\n${short}\n${long}\n${short}` |
| 17 | +}; |
| 18 | + |
| 19 | +const parsed = { |
| 20 | + simple: parse(messages.simple), |
| 21 | + empty: parse(messages.empty), |
| 22 | + short: parse(messages.short), |
| 23 | + long: parse(messages.long) |
| 24 | +}; |
| 25 | + |
| 26 | +test('with simple should succeed', async t => { |
| 27 | + const [actual] = check(await parsed.simple, '', value); |
| 28 | + const expected = true; |
| 29 | + t.is(actual, expected); |
| 30 | +}); |
| 31 | + |
| 32 | +test('with empty should succeed', async t => { |
| 33 | + const [actual] = check(await parsed.empty, '', value); |
| 34 | + const expected = true; |
| 35 | + t.is(actual, expected); |
| 36 | +}); |
| 37 | + |
| 38 | +test('with short should succeed', async t => { |
| 39 | + const [actual] = check(await parsed.short, '', value); |
| 40 | + const expected = true; |
| 41 | + t.is(actual, expected); |
| 42 | +}); |
| 43 | + |
| 44 | +test('with long should fail', async t => { |
| 45 | + const [actual] = check(await parsed.long, '', value); |
| 46 | + const expected = false; |
| 47 | + t.is(actual, expected); |
| 48 | +}); |
| 49 | + |
| 50 | +test('with short with multiple lines should succeed', async t => { |
| 51 | + const [actual] = check(await parsed.short, '', value); |
| 52 | + const expected = true; |
| 53 | + t.is(actual, expected); |
| 54 | +}); |
| 55 | + |
| 56 | +test('with long with multiple lines should fail', async t => { |
| 57 | + const [actual] = check(await parsed.long, '', value); |
| 58 | + const expected = false; |
| 59 | + t.is(actual, expected); |
| 60 | +}); |
0 commit comments