Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pam- committed Mar 1, 2021
1 parent 5b9e614 commit fb9e08e
Show file tree
Hide file tree
Showing 4 changed files with 4,373 additions and 752 deletions.
22 changes: 16 additions & 6 deletions __tests__/utils.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,19 @@ describe('Utils', () => {
it('links to the action workflow', () => {
const attachments = buildSlackAttachments({ status: 'STARTED', color: 'good', github: GITHUB_PUSH_EVENT });

expect(attachments[0].fields.find(a => a.title === 'Action')).toEqual({
title: 'Action',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/commit/abc123/checks | CI>`,
expect(attachments[0].fields.find(a => a.title === 'Workflow')).toEqual({
title: 'Workflow',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/actions/runs/12345 | CI>`,
short: true,
});
});

it('links to the action job', () => {
const attachments = buildSlackAttachments({ status: 'STARTED', color: 'good', github: GITHUB_PUSH_EVENT });

expect(attachments[0].fields.find(a => a.title === 'Job')).toEqual({
title: 'Workflow',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/actions/runs/12345 | build and push>`,
short: true,
});
});
Expand Down Expand Up @@ -65,9 +75,9 @@ describe('Utils', () => {
it('links to the action workflow', () => {
const attachments = buildSlackAttachments({ status: 'STARTED', color: 'good', github: GITHUB_PR_EVENT });

expect(attachments[0].fields.find(a => a.title === 'Action')).toEqual({
title: 'Action',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/commit/xyz678/checks | CI>`,
expect(attachments[0].fields.find(a => a.title === 'Workflow')).toEqual({
title: 'Workflow',
value: `<https://github.com/voxmedia/github-action-slack-notify-build/actions/runs/12345 | CI>`,
short: true,
});
});
Expand Down
5,091 changes: 4,351 additions & 740 deletions dist/index.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export const GITHUB_PUSH_EVENT = {
workflow: 'CI',
eventName: 'push',
sha: 'abc123',
job: 'ci',
runId: 12345
job: 'build and push',
runId: 12345,
},
};

Expand All @@ -35,7 +35,7 @@ export const GITHUB_PR_EVENT = {
workflow: 'CI',
eventName: 'pull_request',
sha: 'abc123',
job: 'ci',
runId: 12345
job: 'build and push',
runId: 12345,
},
};
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ function buildSlackAttachments({ status, color, github }) {
fields: [
{
title: 'Workflow',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId}/ | ${workflow}>`,
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${workflow}>`,
short: true,
},
{
title: 'Job',
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId}/ | ${job}>`,
value: `<https://github.com/${owner}/${repo}/actions/runs/${runId} | ${job}>`,
short: true,
},
{
Expand Down

0 comments on commit fb9e08e

Please sign in to comment.