Skip to content

Commit 924fa33

Browse files
fix(action): fix get event data from issue_coment (#58)
1 parent c3686e7 commit 924fa33

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

__tests__/get-action-data.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ const mockGithubContext = {
174174
};
175175

176176
/* eslint-enable camelcase */
177-
test('getActionData should return a formatted object', t => {
177+
test('getActionData should return a formatted object from issue', t => {
178178
t.deepEqual(getActionData(mockGithubContext), {
179179
action: 'opened',
180180
eventName: 'issues',
@@ -183,6 +183,28 @@ test('getActionData should return a formatted object', t => {
183183
});
184184
});
185185

186+
test('getActionData should return a formatted object from comment', t => {
187+
/* eslint-disable camelcase */
188+
const context = {
189+
eventName: 'issue_comment',
190+
payload: {
191+
action: 'created',
192+
issue: {
193+
node_id: 'MDFooBar45',
194+
html_url: 'https://github.com/alex-page/test-actions/issues/52'
195+
}
196+
}
197+
};
198+
199+
/* eslint-enable camelcase */
200+
t.deepEqual(getActionData(context), {
201+
action: 'created',
202+
eventName: 'issue_comment',
203+
nodeId: 'MDFooBar45',
204+
url: 'https://github.com/alex-page/test-actions/issues/52'
205+
});
206+
});
207+
186208
test('getActionData should fail when eventName is not issues or pull_request', t => {
187209
const failingMockGithubContext = Object.assign({}, mockGithubContext);
188210
const eventName = 'label';

dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/get-action-data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const getActionData = githubContext => {
99
throw new Error(`Only pull requests, issues or comments allowed, received:\n${eventName}`);
1010
}
1111

12-
const githubData = eventName === 'issues' ?
12+
const githubData = eventName === 'issues' || eventName === 'issue_comment' ?
1313
payload.issue :
1414
payload.pull_request;
1515

0 commit comments

Comments
 (0)