|
| 1 | +import test from 'ava'; |
| 2 | +import parse from '../../source/library/parse'; |
| 3 | +import footerLeadingBlank from '../../source/rules/footer-leading-blank'; |
| 4 | + |
| 5 | +const messages = { |
| 6 | + simple: 'chore: subject', |
| 7 | + body: 'chore: subject\nbody', |
| 8 | + trailing: 'chore: subject\nbody\n\n', |
| 9 | + without: 'chore: subject\nbody\nBREAKING CHANGE: something important', |
| 10 | + with: 'chore: subject\nbody\n\nBREAKING CHANGE: something important' |
| 11 | +}; |
| 12 | + |
| 13 | +const parsed = { |
| 14 | + simple: parse(messages.simple), |
| 15 | + body: parse(messages.body), |
| 16 | + trailing: parse(messages.trailing), |
| 17 | + without: parse(messages.without), |
| 18 | + with: parse(messages.with) |
| 19 | +}; |
| 20 | + |
| 21 | +test('footer-leading-blank with simple message should succeed for empty keyword', t => { |
| 22 | + const [actual] = footerLeadingBlank(parsed.simple); |
| 23 | + const expected = true; |
| 24 | + t.is(actual, expected); |
| 25 | +}); |
| 26 | + |
| 27 | +test('footer-leading-blank with simple message should succeed for "never"', t => { |
| 28 | + const [actual] = footerLeadingBlank(parsed.simple, 'never'); |
| 29 | + const expected = true; |
| 30 | + t.is(actual, expected); |
| 31 | +}); |
| 32 | + |
| 33 | +test('footer-leading-blank with simple message should succeed for "always"', t => { |
| 34 | + const [actual] = footerLeadingBlank(parsed.simple, 'always'); |
| 35 | + const expected = true; |
| 36 | + t.is(actual, expected); |
| 37 | +}); |
| 38 | + |
| 39 | +test('footer-leading-blank with body message should succeed for empty keyword', t => { |
| 40 | + const [actual] = footerLeadingBlank(parsed.body); |
| 41 | + const expected = true; |
| 42 | + t.is(actual, expected); |
| 43 | +}); |
| 44 | + |
| 45 | +test('footer-leading-blank with body message should succeed for "never"', t => { |
| 46 | + const [actual] = footerLeadingBlank(parsed.body, 'never'); |
| 47 | + const expected = true; |
| 48 | + t.is(actual, expected); |
| 49 | +}); |
| 50 | + |
| 51 | +test('footer-leading-blank with body message should succeed for "always"', t => { |
| 52 | + const [actual] = footerLeadingBlank(parsed.body, 'always'); |
| 53 | + const expected = true; |
| 54 | + t.is(actual, expected); |
| 55 | +}); |
| 56 | + |
| 57 | +test('footer-leading-blank with trailing message should succeed for empty keyword', t => { |
| 58 | + const [actual] = footerLeadingBlank(parsed.trailing); |
| 59 | + const expected = true; |
| 60 | + t.is(actual, expected); |
| 61 | +}); |
| 62 | + |
| 63 | +test('footer-leading-blank with trailing message should succeed for "never"', t => { |
| 64 | + const [actual] = footerLeadingBlank(parsed.trailing, 'never'); |
| 65 | + const expected = true; |
| 66 | + t.is(actual, expected); |
| 67 | +}); |
| 68 | + |
| 69 | +test('footer-leading-blank with trailing message should succeed for "always"', t => { |
| 70 | + const [actual] = footerLeadingBlank(parsed.trailing, 'always'); |
| 71 | + const expected = true; |
| 72 | + t.is(actual, expected); |
| 73 | +}); |
| 74 | + |
| 75 | +test('footer-leading-blank without blank line before footer should fail for empty keyword', t => { |
| 76 | + const [actual] = footerLeadingBlank(parsed.without); |
| 77 | + const expected = false; |
| 78 | + t.is(actual, expected); |
| 79 | +}); |
| 80 | + |
| 81 | +test('footer-leading-blank without blank line before footer should succeed for "never"', t => { |
| 82 | + const [actual] = footerLeadingBlank(parsed.without, 'never'); |
| 83 | + const expected = true; |
| 84 | + t.is(actual, expected); |
| 85 | +}); |
| 86 | + |
| 87 | +test('footer-leading-blank without blank line before footer should fail for "always"', t => { |
| 88 | + const [actual] = footerLeadingBlank(parsed.without, 'always'); |
| 89 | + const expected = false; |
| 90 | + t.is(actual, expected); |
| 91 | +}); |
| 92 | + |
| 93 | +test('footer-leading-blank with blank line before footer should succeed for empty keyword', t => { |
| 94 | + const [actual] = footerLeadingBlank(parsed.with); |
| 95 | + const expected = true; |
| 96 | + t.is(actual, expected); |
| 97 | +}); |
| 98 | + |
| 99 | +test('footer-leading-blank with blank line before footer should fail for "never"', t => { |
| 100 | + const [actual] = footerLeadingBlank(parsed.with, 'never'); |
| 101 | + const expected = false; |
| 102 | + t.is(actual, expected); |
| 103 | +}); |
| 104 | + |
| 105 | +test('footer-leading-blank with blank line before footer should succeed for "always"', t => { |
| 106 | + const [actual] = footerLeadingBlank(parsed.with, 'always'); |
| 107 | + const expected = true; |
| 108 | + t.is(actual, expected); |
| 109 | +}); |
0 commit comments