Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pam- committed Mar 2, 2021
1 parent 60248a1 commit 0476331
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 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: 'Job',
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
4 changes: 4 additions & 0 deletions fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const GITHUB_PUSH_EVENT = {
workflow: 'CI',
eventName: 'push',
sha: 'abc123',
job: 'build and push',
runId: 12345,
},
};

Expand All @@ -33,5 +35,7 @@ export const GITHUB_PR_EVENT = {
workflow: 'CI',
eventName: 'pull_request',
sha: 'abc123',
job: 'build and push',
runId: 12345,
},
};

0 comments on commit 0476331

Please sign in to comment.