2018-09-18 16:59:06 +03:00
|
|
|
var should = require('should'),
|
|
|
|
sinon = require('sinon'),
|
|
|
|
proxyquire = require('proxyquire'),
|
|
|
|
sandbox = sinon.sandbox.create();
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
beforeEach(function () {
|
|
|
|
use = sandbox.spy();
|
|
|
|
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();
|
|
|
|
|
|
|
|
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,
|
|
|
|
'./site': siteSpy
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sandbox.restore();
|
|
|
|
});
|
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
});
|