|
| 1 | +import test from 'ava'; |
| 2 | +import parse from '../library/parse'; |
| 3 | +import check from './signed-off-by'; |
| 4 | + |
| 5 | +const messages = { |
| 6 | + empty: 'chore:\n', |
| 7 | + with: `chore: subject\nbody\nfooter\nSigned-off-by:\n\n`, |
| 8 | + without: `chore: subject\nbody\nfooter\n\n`, |
| 9 | + inSubject: `chore: subject Signed-off-by:\nbody\nfooter\n\n`, |
| 10 | + inBody: `chore: subject\nbody Signed-off-by:\nfooter\n\n` |
| 11 | +}; |
| 12 | + |
| 13 | +const parsed = { |
| 14 | + empty: parse(messages.empty), |
| 15 | + with: parse(messages.with), |
| 16 | + without: parse(messages.without), |
| 17 | + inSubject: parse(messages.inSubject), |
| 18 | + inBody: parse(messages.inBody) |
| 19 | +}; |
| 20 | + |
| 21 | +test('empty against "always signed-off-by" should fail', async t => { |
| 22 | + const [actual] = check(await parsed.empty, 'always', 'Signed-off-by:'); |
| 23 | + const expected = false; |
| 24 | + t.is(actual, expected); |
| 25 | +}); |
| 26 | + |
| 27 | +test('empty against "never signed-off-by" should succeed', async t => { |
| 28 | + const [actual] = check(await parsed.empty, 'never', 'Signed-off-by:'); |
| 29 | + const expected = true; |
| 30 | + t.is(actual, expected); |
| 31 | +}); |
| 32 | + |
| 33 | +test('with against "always signed-off-by" should succeed', async t => { |
| 34 | + const [actual] = check(await parsed.with, 'always', 'Signed-off-by:'); |
| 35 | + const expected = true; |
| 36 | + t.is(actual, expected); |
| 37 | +}); |
| 38 | + |
| 39 | +test('with against "never signed-off-by" should fail', async t => { |
| 40 | + const [actual] = check(await parsed.with, 'never', 'Signed-off-by:'); |
| 41 | + const expected = false; |
| 42 | + t.is(actual, expected); |
| 43 | +}); |
| 44 | + |
| 45 | +test('without against "always signed-off-by" should fail', async t => { |
| 46 | + const [actual] = check(await parsed.without, 'always', 'Signed-off-by:'); |
| 47 | + const expected = false; |
| 48 | + t.is(actual, expected); |
| 49 | +}); |
| 50 | + |
| 51 | +test('without against "never signed-off-by" should succeed', async t => { |
| 52 | + const [actual] = check(await parsed.without, 'never', 'Signed-off-by:'); |
| 53 | + const expected = true; |
| 54 | + t.is(actual, expected); |
| 55 | +}); |
| 56 | + |
| 57 | +test('inSubject against "always signed-off-by" should fail', async t => { |
| 58 | + const [actual] = check(await parsed.inSubject, 'always', 'Signed-off-by:'); |
| 59 | + const expected = false; |
| 60 | + t.is(actual, expected); |
| 61 | +}); |
| 62 | + |
| 63 | +test('inSubject against "never signed-off-by" should succeed', async t => { |
| 64 | + const [actual] = check(await parsed.inSubject, 'never', 'Signed-off-by:'); |
| 65 | + const expected = true; |
| 66 | + t.is(actual, expected); |
| 67 | +}); |
| 68 | + |
| 69 | +test('inBody against "always signed-off-by" should fail', async t => { |
| 70 | + const [actual] = check(await parsed.inBody, 'always', 'Signed-off-by:'); |
| 71 | + const expected = false; |
| 72 | + t.is(actual, expected); |
| 73 | +}); |
| 74 | + |
| 75 | +test('inBody against "never signed-off-by" should succeed', async t => { |
| 76 | + const [actual] = check(await parsed.inBody, 'never', 'Signed-off-by:'); |
| 77 | + const expected = true; |
| 78 | + t.is(actual, expected); |
| 79 | +}); |
0 commit comments