UNPKG

1.31 kBtext/coffeescriptView Raw
1shmock = require 'shmock'
2Slack = require '../src/slack'
3
4SLACK_HOST_PORT = 0x51ac
5
6describe 'Slack', ->
7 @timeout 30000
8
9 before ->
10 process.env.SLACK_CHANNEL_URL = 'http://localhost:' + SLACK_HOST_PORT + '/slackTest'
11 @slackHost = shmock SLACK_HOST_PORT
12 @CANARY_UPDATE_INTERVAL = process.env.CANARY_UPDATE_INTERVAL = 1000*120
13 @CANARY_HEALTH_CHECK_MAX_DIFF = process.env.CANARY_HEALTH_CHECK_MAX_DIFF = 100
14
15 @sut = new Slack @CANARY_UPDATE_INTERVAL, @CANARY_HEALTH_CHECK_MAX_DIFF
16
17 after (done) ->
18 @slackHost.close done
19
20 describe '-> slack', ->
21 it 'should have a sendSlackNotifications function', ->
22 expect(@sut.sendSlackNotifications).to.exist
23
24 describe 'when sendSlackNotifications is called with a passing flow', ->
25 before (done) ->
26 @stats = {
27 flows: {
28 'fancy-uuid': {
29 name: "Collect Test",
30 timeDiffs: [
31 120000
32 ]
33 }
34 }
35 }
36 sinon.spy(@sut, 'curryPostSlackNotification')
37 @sut.sendSlackNotifications @stats, done
38 @slackPost = @slackHost.post('/slackTest').reply(200)
39
40 it 'should call curryPostSlackNotification with passing message', ->
41 expect(@slackPost.isDone).to.be.true