2018-09-18 16:59:06 +03:00
|
|
|
var should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
2019-01-21 19:53:44 +03:00
|
|
|
proxyquire = require('proxyquire');
|
2018-09-18 16:59:06 +03:00
|
|
|
|
|
|
|
describe('parent app', function () {
|
|
|
|
let expressStub;
|
|
|
|
let use;
|
2018-11-26 12:35:38 +03:00
|
|
|
let apiSpy;
|
2018-09-18 16:59:06 +03:00
|
|
|
let parentApp;
|
|
|
|
let adminSpy;
|
|
|
|
let siteSpy;
|
2019-05-08 15:08:25 +03:00
|
|
|
let gatewaySpy;
|
|
|
|
let authPagesSpy;
|
2018-09-18 16:59:06 +03:00
|
|
|
|
|
|
|
beforeEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
use = sinon.spy();
|
2018-09-18 16:59:06 +03:00
|
|
|
expressStub = () => ({
|
|
|
|
use,
|
|
|
|
enable: () => {}
|
|
|
|
});
|
|
|
|
|
2018-11-26 12:35:38 +03:00
|
|
|
apiSpy = sinon.spy();
|
2018-09-18 16:59:06 +03:00
|
|
|
adminSpy = sinon.spy();
|
|
|
|
siteSpy = sinon.spy();
|
2019-05-08 15:08:25 +03:00
|
|
|
gatewaySpy = sinon.spy();
|
|
|
|
authPagesSpy = sinon.spy();
|
2018-09-18 16:59:06 +03:00
|
|
|
|
|
|
|
parentApp = proxyquire('../../../server/web/parent-app', {
|
|
|
|
express: expressStub,
|
2018-11-26 12:35:38 +03:00
|
|
|
'./api': apiSpy,
|
2018-09-18 16:59:06 +03:00
|
|
|
'./admin': adminSpy,
|
2019-05-08 15:08:25 +03:00
|
|
|
'./site': siteSpy,
|
|
|
|
'../services/members': {
|
|
|
|
gateway: gatewaySpy,
|
|
|
|
authPages: authPagesSpy
|
|
|
|
}
|
2018-09-18 16:59:06 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
2019-01-21 19:53:44 +03:00
|
|
|
sinon.restore();
|
2018-09-18 16:59:06 +03:00
|
|
|
});
|
|
|
|
|
2018-11-26 12:35:38 +03:00
|
|
|
it('should mount 3 apps and assign correct routes to them', function () {
|
2018-09-18 16:59:06 +03:00
|
|
|
parentApp();
|
|
|
|
|
2018-11-26 12:35:38 +03:00
|
|
|
use.calledWith('/ghost/api').should.be.true();
|
2018-09-18 16:59:06 +03:00
|
|
|
use.calledWith('/ghost').should.be.true();
|
|
|
|
|
2018-11-26 12:35:38 +03:00
|
|
|
apiSpy.called.should.be.true();
|
2018-09-18 16:59:06 +03:00
|
|
|
adminSpy.called.should.be.true();
|
|
|
|
siteSpy.called.should.be.true();
|
|
|
|
});
|
|
|
|
});
|