Skip to content
This repository was archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
Call init on successful webhook (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bouncey authored Oct 2, 2017
1 parent 5f3bfef commit ac6ee68
Show file tree
Hide file tree
Showing 4 changed files with 489 additions and 11 deletions.
31 changes: 22 additions & 9 deletions server/endpoints/webhooks/__tests__/webhook-guides.test.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
const assert = require('chai').assert;
const should = require('chai').should();
/* global describe beforeEach it */
const express = require('express');
const proxyquire = require('proxyquire');
const sinon = require('sinon');
const supertest = require('supertest');
const bodyParser = require('body-parser');

const {
fullScale,
masterMergedPR,
masterNotMergedPR,
masterPROpen,
notMasterMergedPR
} = require('./webhookPayloads');

describe('POST /guides', () => {
let guideUpdateStub, app, route, request;
let callInitStub, app, route, request;
beforeEach(function () {
guideUpdateStub = sinon.stub();
callInitStub = sinon.stub();
app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
route = proxyquire('../webhook-guides', {
'../../../init/guides': guideUpdateStub
'./callInit': callInitStub
});
route(app);
request = supertest(app);
Expand All @@ -38,7 +38,7 @@ describe('POST /guides', () => {
.post('/guides')
.send(masterPROpen)
.expect(() => {
if (guideUpdateStub.called) {
if (callInitStub.called) {
throw new Error('guide update called!');
}
})
Expand All @@ -51,7 +51,7 @@ describe('POST /guides', () => {
.send(masterNotMergedPR)
.expect(200)
.expect(() => {
if (guideUpdateStub.called) {
if (callInitStub.called) {
throw new Error('guide update called!');
}
})
Expand All @@ -64,7 +64,7 @@ describe('POST /guides', () => {
.send(notMasterMergedPR)
.expect(200)
.expect(() => {
if (guideUpdateStub.called) {
if (callInitStub.called) {
throw new Error('guide update called!');
}
})
Expand All @@ -77,7 +77,20 @@ describe('POST /guides', () => {
.send(masterMergedPR)
.expect(200)
.expect(() => {
if (!guideUpdateStub.called) {
if (!callInitStub.called) {
throw new Error('guide update wasn\'t called!');
}
})
.end(done);
});

it('should call update when PR is merged on master, FULL SCALE', done => {
request
.post('/guides')
.send(fullScale)
.expect(200)
.expect(() => {
if (!callInitStub.called) {
throw new Error('guide update wasn\'t called!');
}
})
Expand Down
Loading

0 comments on commit ac6ee68

Please sign in to comment.