|
| 1 | +import test from 'ava'; |
| 2 | +import parse from '../library/parse'; |
| 3 | +import referencesEmpty from './references-empty'; |
| 4 | + |
| 5 | +const messages = { |
| 6 | + plain: 'foo: bar', |
| 7 | + comment: 'foo: baz\n#1 Comment', |
| 8 | + reference: '#comment\nfoo: baz \nCloses #1', |
| 9 | + references: '#comment\nfoo: bar \nCloses #1, #2, #3' |
| 10 | +}; |
| 11 | + |
| 12 | +const parsed = { |
| 13 | + plain: parse(messages.plain), |
| 14 | + comment: parse(messages.comment), |
| 15 | + reference: parse(messages.reference), |
| 16 | + references: parse(messages.references) |
| 17 | +}; |
| 18 | + |
| 19 | +test('defaults to never and fails for plain', async t => { |
| 20 | + const [actual] = referencesEmpty(await parsed.plain); |
| 21 | + const expected = false; |
| 22 | + t.is(actual, expected); |
| 23 | +}); |
| 24 | + |
| 25 | +test('defaults to never and succeeds for reference', async t => { |
| 26 | + const [actual] = referencesEmpty(await parsed.reference); |
| 27 | + const expected = true; |
| 28 | + t.is(actual, expected); |
| 29 | +}); |
| 30 | + |
| 31 | +test('fails for comment with never', async t => { |
| 32 | + const [actual] = referencesEmpty(await parsed.comment, 'never'); |
| 33 | + const expected = false; |
| 34 | + t.is(actual, expected); |
| 35 | +}); |
| 36 | + |
| 37 | +test('succeeds for comment with always', async t => { |
| 38 | + const [actual] = referencesEmpty(await parsed.comment, 'always'); |
| 39 | + const expected = true; |
| 40 | + t.is(actual, expected); |
| 41 | +}); |
| 42 | + |
| 43 | +test('succeeds for reference with never', async t => { |
| 44 | + const [actual] = referencesEmpty(await parsed.reference, 'never'); |
| 45 | + const expected = true; |
| 46 | + t.is(actual, expected); |
| 47 | +}); |
| 48 | + |
| 49 | +test('fails for reference with always', async t => { |
| 50 | + const [actual] = referencesEmpty(await parsed.reference, 'always'); |
| 51 | + const expected = false; |
| 52 | + t.is(actual, expected); |
| 53 | +}); |
| 54 | + |
| 55 | +test('succeeds for references with never', async t => { |
| 56 | + const [actual] = referencesEmpty(await parsed.references, 'never'); |
| 57 | + const expected = true; |
| 58 | + t.is(actual, expected); |
| 59 | +}); |
| 60 | + |
| 61 | +test('fails for references with always', async t => { |
| 62 | + const [actual] = referencesEmpty(await parsed.references, 'always'); |
| 63 | + const expected = false; |
| 64 | + t.is(actual, expected); |
| 65 | +}); |
0 commit comments