Skip to content

Commit fed92b6

Browse files
committed
Improve tests
1 parent 9b70537 commit fed92b6

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

tests/__snapshots__/index.test.js.snap

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,25 @@ Array [
9393
"An error occurred while creating the issue. This might be caused by a malformed issue title, or a typo in the labels or assignees. Check .github/ISSUE_TEMPLATE.md!",
9494
],
9595
Array [
96-
[HttpError: request to https://api.github.com/repos/JasonEtco/waddup/issues failed, reason: Oh no something borked!],
96+
[HttpError: Validation error],
97+
],
98+
]
99+
`;
100+
101+
exports[`create-an-issue logs a helpful error if creating an issue throws an error with more errors 1`] = `
102+
Array [
103+
Array [
104+
"An error occurred while creating the issue. This might be caused by a malformed issue title, or a typo in the labels or assignees. Check .github/ISSUE_TEMPLATE.md!",
105+
],
106+
Array [
107+
[HttpError: Validation error],
108+
],
109+
Array [
110+
Array [
111+
Object {
112+
"foo": true,
113+
},
114+
],
97115
],
98116
]
99117
`;

tests/index.test.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,24 @@ describe('create-an-issue', () => {
7575
it('logs a helpful error if creating an issue throws an error', async () => {
7676
nock.cleanAll()
7777
nock('https://api.github.com')
78-
.post(/\/repos\/.*\/.*\/issues/).replyWithError('Oh no something borked!')
78+
.post(/\/repos\/.*\/.*\/issues/).reply(500, {
79+
message: 'Validation error'
80+
})
81+
82+
await actionFn(tools)
83+
expect(tools.log.error).toHaveBeenCalled()
84+
expect(tools.log.error.mock.calls).toMatchSnapshot()
85+
expect(tools.exit.failure).toHaveBeenCalled()
86+
})
87+
88+
it('logs a helpful error if creating an issue throws an error with more errors', async () => {
89+
nock.cleanAll()
90+
nock('https://api.github.com')
91+
.post(/\/repos\/.*\/.*\/issues/).reply(500, {
92+
message: 'Validation error',
93+
errors: [{ foo: true }]
94+
})
95+
7996
await actionFn(tools)
8097
expect(tools.log.error).toHaveBeenCalled()
8198
expect(tools.log.error.mock.calls).toMatchSnapshot()

0 commit comments

Comments
 (0)