From a92dec9cdae2c6af450a191518324aff0a589cef Mon Sep 17 00:00:00 2001 From: Gregor Date: Tue, 21 Nov 2017 23:34:12 -0800 Subject: [PATCH] test: custom event properties --- test/integration/server-test.js | 38 ++++++--------------------------- 1 file changed, 7 insertions(+), 31 deletions(-) diff --git a/test/integration/server-test.js b/test/integration/server-test.js index 53adcb80..bf852194 100644 --- a/test/integration/server-test.js +++ b/test/integration/server-test.js @@ -55,9 +55,15 @@ test('GET /', (t) => { }) test('POST / with push event payload', {only: true}, (t) => { + t.plan(2) + const api = new Webhooks({secret: 'mysecret'}) const server = http.createServer(api.middleware) + api.on('push', (event) => { + t.is(event.id, '123e4567-e89b-12d3-a456-426655440000') + }) + promisify(server.listen.bind(server))(this.port) .then(() => { @@ -77,37 +83,7 @@ test('POST / with push event payload', {only: true}, (t) => { }) .then(() => { - server.close(t.end) - }) - - .catch(t.error) -}) - -test('POST / with push event payload (without signature)', (t) => { - const api = new Webhooks({secret: 'mysecret'}) - const server = http.createServer(api.middleware) - - promisify(server.listen.bind(server))(this.port) - - .then(() => { - return axios.post(`http://localhost:${this.port}`, pushEventPayload, { - headers: { - 'X-GitHub-Delivery': '123e4567-e89b-12d3-a456-426655440000', - 'X-GitHub-Event': 'push' - } - }) - }) - - .then(() => { - t.fail('should return a 400') - }) - - .catch(error => { - t.is(error.response.status, 400) - }) - - .then(() => { - server.close(t.end) + server.close() }) .catch(t.error)