Skip to content

Commit

Permalink
test(rules): add issue prefix case
Browse files Browse the repository at this point in the history
  • Loading branch information
marionebl committed Dec 26, 2017
1 parent 11674b4 commit d5fba83
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions @commitlint/rules/src/references-empty.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ const messages = {
plain: 'foo: bar',
comment: 'foo: baz\n#1 Comment',
reference: '#comment\nfoo: baz \nCloses #1',
references: '#comment\nfoo: bar \nCloses #1, #2, #3'
references: '#comment\nfoo: bar \nCloses #1, #2, #3',
prefix: 'bar REF-1234'
};

const opts = (async () => {
Expand All @@ -24,7 +25,10 @@ const parsed = {
reference: (async () =>
parse(messages.reference, undefined, (await opts).parserOpts))(),
references: (async () =>
parse(messages.references, undefined, (await opts).parserOpts))()
parse(messages.references, undefined, (await opts).parserOpts))(),
prefix: parse(messages.prefix, undefined, {
issuePrefixes: ['REF-']
})
};

test('defaults to never and fails for plain', async t => {
Expand Down Expand Up @@ -74,3 +78,9 @@ test('fails for references with always', async t => {
const expected = false;
t.is(actual, expected);
});

test('succeeds for custom references with always', async t => {
const [actual] = referencesEmpty(await parsed.prefix, 'never');
const expected = true;
t.is(actual, expected);
});

0 comments on commit d5fba83

Please sign in to comment.