|
| 1 | +import parse from '@commitlint/parse'; |
| 2 | +import {bodyFullStop} from './body-full-stop'; |
| 3 | + |
| 4 | +const messages = { |
| 5 | + empty: 'test:\n', |
| 6 | + with: `test: subject\n\nbody.`, |
| 7 | + without: `test: subject\n\nbody`, |
| 8 | +}; |
| 9 | + |
| 10 | +const parsed = { |
| 11 | + empty: parse(messages.empty), |
| 12 | + with: parse(messages.with), |
| 13 | + without: parse(messages.without), |
| 14 | +}; |
| 15 | + |
| 16 | +test('empty against "always" should succeed', async () => { |
| 17 | + const [actual] = bodyFullStop(await parsed.empty, 'always', '.'); |
| 18 | + const expected = true; |
| 19 | + expect(actual).toEqual(expected); |
| 20 | +}); |
| 21 | + |
| 22 | +test('empty against "never ." should succeed', async () => { |
| 23 | + const [actual] = bodyFullStop(await parsed.empty, 'never', '.'); |
| 24 | + const expected = true; |
| 25 | + expect(actual).toEqual(expected); |
| 26 | +}); |
| 27 | + |
| 28 | +test('with against "always ." should succeed', async () => { |
| 29 | + const [actual] = bodyFullStop(await parsed.with, 'always', '.'); |
| 30 | + const expected = true; |
| 31 | + expect(actual).toEqual(expected); |
| 32 | +}); |
| 33 | + |
| 34 | +test('with against "never ." should fail', async () => { |
| 35 | + const [actual] = bodyFullStop(await parsed.with, 'never', '.'); |
| 36 | + const expected = false; |
| 37 | + expect(actual).toEqual(expected); |
| 38 | +}); |
| 39 | + |
| 40 | +test('without against "always ." should fail', async () => { |
| 41 | + const [actual] = bodyFullStop(await parsed.without, 'always', '.'); |
| 42 | + const expected = false; |
| 43 | + expect(actual).toEqual(expected); |
| 44 | +}); |
| 45 | + |
| 46 | +test('without against "never ." should succeed', async () => { |
| 47 | + const [actual] = bodyFullStop(await parsed.without, 'never', '.'); |
| 48 | + const expected = true; |
| 49 | + expect(actual).toEqual(expected); |
| 50 | +}); |
0 commit comments