Skip to content

Commit

Permalink
Merge pull request #8 from probot/report-failures
Browse files Browse the repository at this point in the history
Throw error when failing to parse
  • Loading branch information
bkeepers committed Oct 19, 2017
2 parents 92a9310 + 22420c1 commit b1676e8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ module.exports = {
}));
} else {
await context.github.issues.createComment(context.issue({
body: `@${context.payload.sender.login} we had trouble parsing your reminder`
body: `@${context.payload.sender.login} we had trouble parsing your reminder. Try:\n\n\`/remind me [what] [when]\``
}));
throw new Error(`Unable to parse reminder: remind ${command.arguments}`);
}
},

Expand Down
18 changes: 18 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ describe('reminders', () => {
});
});

it('sets a reminder with slash commands', async () => {
commentEvent.payload.comment.body = '/remind nope';

try {
await robot.receive(commentEvent);
throw new Error('Expected error but none was raised');
} catch (err) {
expect(err.message).toEqual('Unable to parse reminder: remind nope');
}

expect(github.issues.createComment).toHaveBeenCalledWith({
number: 2,
owner: 'baxterthehacker',
repo: 'public-repo',
body: '@baxterthehacker we had trouble parsing your reminder. Try:\n\n`/remind me [what] [when]`'
});
});

it('test visitor activation', async () => {
await robot.receive({
event: 'schedule',
Expand Down

0 comments on commit b1676e8

Please sign in to comment.