Skip to content

Commit

Permalink
fix: only add one example JIRA key to warning (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilkimmett authored and macklinu committed Oct 12, 2018
1 parent 17459d5 commit 56dee38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ describe('jiraIssue()', () => {
'Please add the JIRA issue key to the PR title (e.g. ABC-123)'
)
})
it('only adds one example key to warning', () => {
global.danger = { github: { pr: { title: 'Change some things' } } }
jiraIssue({
key: ['ABC', 'DEF'],
url: 'https://jira.net/browse',
})
expect(global.warn).toHaveBeenCalledWith(
'Please add the JIRA issue key to the PR title (e.g. ABC-123)'
)
})
it('adds the JIRA issue link to the messages table', () => {
global.danger = {
github: { pr: { title: '[ABC-808] Change some things' } },
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ export default function jiraIssue(options: Options) {
message(`${emoji} ${jiraUrls.join(', ')}`)
}
} else {
const firstKey = Array.isArray(key) ? key[0] : key
warn(
`Please add the JIRA issue key to the PR ${location} (e.g. ${key}-123)`
`Please add the JIRA issue key to the PR ${location} (e.g. ${firstKey}-123)`
)
}
}

0 comments on commit 56dee38

Please sign in to comment.