-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
12686c3
commit 4ca3e5d
Showing
8 changed files
with
175 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { SlackService } from '../slack.service'; | ||
import { createApp } from './fixtures'; | ||
import * as nock from 'nock'; | ||
|
||
describe('webhook', () => { | ||
let service: SlackService; | ||
let output: any; | ||
|
||
const baseUrl = 'https://example.com'; | ||
|
||
beforeEach(async () => { | ||
output = jest.fn(); | ||
const app = await createApp({ | ||
type: 'webhook', | ||
webhookOptions: { url: `${baseUrl}/webhook` }, | ||
}); | ||
service = app.get<SlackService>(SlackService); | ||
}); | ||
|
||
it('must send requests to API', async () => { | ||
// nock.recorder.rec(); | ||
const scope = nock(baseUrl, { encodedQueryParams: true }) | ||
.post('/webhook', { | ||
text: 'hello-world', | ||
}) | ||
.reply(200, 'ok'); | ||
|
||
await service.postMessage({ text: 'hello-world' }); | ||
|
||
scope.done(); | ||
}); | ||
|
||
it('Should throw when request fails', () => { | ||
nock(baseUrl, { encodedQueryParams: true }) | ||
.post('/webhook', { | ||
text: 'hello-world', | ||
}) | ||
.reply(500, 'fail'); | ||
|
||
return service | ||
.postMessage({ text: 'hello-world' }) | ||
.catch(error => | ||
expect(error).toMatchInlineSnapshot( | ||
`[Error: Could not send request to Slack Webhook: fail]`, | ||
), | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const SLACK_MODULE_OPTIONS = 'SlackModuleOptions'; | ||
export const SLACK_WEB_CLIENT = 'SlackWebClient'; | ||
export const SLACK_WEBHOOK_URL = 'SlackWebhookUrl'; | ||
export const GOOGLE_LOGGING = 'SlackGoogleLogging'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.