forked from nodejs/github-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent-relay-to-github-actions.test.js
More file actions
38 lines (29 loc) · 937 Bytes
/
Copy pathevent-relay-to-github-actions.test.js
File metadata and controls
38 lines (29 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict'
const tap = require('tap')
const url = require('url')
const nock = require('nock')
const supertest = require('supertest')
const { app, events } = require('../../app')
const readFixture = require('../read-fixture')
require('../../scripts/event-relay')(app, events)
tap.test('Sends POST requests to https://api.github.com/repos/nodejs/<repo>/dispatches', (t) => {
const jenkinsPayload = readFixture('success-payload.json')
nock('https://api.github.com')
.filteringPath(ignoreQueryParams)
.post('/repos/nodejs/node/dispatches')
.reply(204)
.on('replied', (req, interceptor) => {
t.doesNotThrow(() => interceptor.scope.done())
})
t.plan(2)
supertest(app)
.post('/node/jenkins/start')
.send(jenkinsPayload)
.expect(200)
.end((err, res) => {
t.equal(err, null)
})
})
function ignoreQueryParams (pathAndQuery) {
return url.parse(pathAndQuery, true).pathname
}