Skip to content

Commit

Permalink
feat: add $ISSUE_NUMBER value to issue creation template
Browse files Browse the repository at this point in the history
Fixes #153
  • Loading branch information
synicalsyntax authored and gr2m committed Oct 2, 2018
1 parent 61a3314 commit ed1aeff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
10 changes: 9 additions & 1 deletion lib/create-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ function createIssue (state) {
labels: state.labels
})

.then((result) => {
.then(async (result) => {
const newContent = content.replace(/\$ISSUE_NUMBER/, result.data.number)

await state.api.issues.edit({
owner: state.owner,
repo: state.issueRepo,
body: newContent
})

state.debug(`issue created: ${result.data.html_url}`)
return result
})
Expand Down
16 changes: 13 additions & 3 deletions test/unit/create-issue-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,35 @@ test('create issue request succeeds', t => {
filename: 'filename',
branchUrl: 'branchUrl'
},
template: 'test value1: $DIFF value2: $FILENAME value3: $BRANCH_URL value4: $REPO'
template: 'test value1: $DIFF value2: $FILENAME value3: $BRANCH_URL value4: $REPO value5: $ISSUE_NUMBER'
}

simple.mock(api.issues, 'create').resolveWith({
data: {
html_url: 'html_url'
html_url: 'html_url',
number: 123
}
})

simple.mock(api.issues, 'edit').resolveWith({
data: {
body: 'test value1: patch value2: filename value3: branchUrl value4: installRepo value5: 123'
}
})

createIssue(state)

.then((response) => {
const createIssueArgs = api.issues.create.lastCall.arg
const editIssueArgs = api.issues.edit.lastCall.arg
t.is(response.data.html_url, 'html_url')
t.is(response.data.number, 123)
t.is(createIssueArgs.title, 'title')
t.is(createIssueArgs.body, 'test value1: patch value2: filename value3: branchUrl value4: installRepo')
t.is(createIssueArgs.body, 'test value1: patch value2: filename value3: branchUrl value4: installRepo value5: $ISSUE_NUMBER')
t.is(createIssueArgs.repo, 'issueRepo')
t.is(createIssueArgs.labels, 'label-1')
t.is(createIssueArgs.owner, 'owner')
t.is(editIssueArgs.body, 'test value1: patch value2: filename value3: branchUrl value4: installRepo value5: 123')

simple.restore()
t.end()
Expand Down

0 comments on commit ed1aeff

Please sign in to comment.