File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ 'use strict'
2+
3+ const tap = require ( 'tap' )
4+ const url = require ( 'url' )
5+ const nock = require ( 'nock' )
6+ const supertest = require ( 'supertest' )
7+
8+ const { app, events } = require ( '../../app' )
9+
10+ const readFixture = require ( '../read-fixture' )
11+
12+ require ( '../../scripts/event-relay' ) ( app , events )
13+
14+ tap . test ( 'Sends POST requests to https://api.github.com/repos/nodejs/<repo>/dispatches' , ( t ) => {
15+ const jenkinsPayload = readFixture ( 'success-payload.json' )
16+
17+ nock ( 'https://api.github.com' )
18+ . filteringPath ( ignoreQueryParams )
19+ . post ( '/repos/nodejs/node/dispatches' )
20+ . reply ( 204 )
21+ . on ( 'replied' , ( req , interceptor ) => {
22+ t . doesNotThrow ( ( ) => interceptor . scope . done ( ) )
23+ } )
24+
25+ t . plan ( 2 )
26+
27+ supertest ( app )
28+ . post ( '/node/jenkins/start' )
29+ . send ( jenkinsPayload )
30+ . expect ( 200 )
31+ . end ( ( err , res ) => {
32+ t . equal ( err , null )
33+ } )
34+ } )
35+
36+ function ignoreQueryParams ( pathAndQuery ) {
37+ return url . parse ( pathAndQuery , true ) . pathname
38+ }
You can’t perform that action at this time.
0 commit comments