Skip to content

Commit

Permalink
fix(action): fix get event data from issue_coment (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
jurijzahn8019 authored Dec 14, 2020
1 parent c3686e7 commit 924fa33
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
24 changes: 23 additions & 1 deletion __tests__/get-action-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const mockGithubContext = {
};

/* eslint-enable camelcase */
test('getActionData should return a formatted object', t => {
test('getActionData should return a formatted object from issue', t => {
t.deepEqual(getActionData(mockGithubContext), {
action: 'opened',
eventName: 'issues',
Expand All @@ -183,6 +183,28 @@ test('getActionData should return a formatted object', t => {
});
});

test('getActionData should return a formatted object from comment', t => {
/* eslint-disable camelcase */
const context = {
eventName: 'issue_comment',
payload: {
action: 'created',
issue: {
node_id: 'MDFooBar45',
html_url: 'https://github.com/alex-page/test-actions/issues/52'
}
}
};

/* eslint-enable camelcase */
t.deepEqual(getActionData(context), {
action: 'created',
eventName: 'issue_comment',
nodeId: 'MDFooBar45',
url: 'https://github.com/alex-page/test-actions/issues/52'
});
});

test('getActionData should fail when eventName is not issues or pull_request', t => {
const failingMockGithubContext = Object.assign({}, mockGithubContext);
const eventName = 'label';
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/get-action-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const getActionData = githubContext => {
throw new Error(`Only pull requests, issues or comments allowed, received:\n${eventName}`);
}

const githubData = eventName === 'issues' ?
const githubData = eventName === 'issues' || eventName === 'issue_comment' ?
payload.issue :
payload.pull_request;

Expand Down

0 comments on commit 924fa33

Please sign in to comment.