2020-04-29 16:44:27 +01:00
|
|
|
const should = require('should');
|
|
|
|
const sinon = require('sinon');
|
2021-10-06 10:52:46 +01:00
|
|
|
const helpers = require('../../../../../core/frontend/services/helpers');
|
|
|
|
const AppProxy = require('../../../../../core/frontend/services/apps/proxy');
|
|
|
|
const routing = require('../../../../../core/frontend/services/routing');
|
2020-03-20 08:58:26 +00:00
|
|
|
|
|
|
|
describe('Apps', function () {
|
|
|
|
beforeEach(function () {
|
|
|
|
sinon.stub(routing.registry, 'getRouter').withArgs('appRouter').returns({
|
|
|
|
mountRouter: sinon.stub()
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function () {
|
|
|
|
sinon.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('Proxy', function () {
|
|
|
|
it('creates a ghost proxy', function () {
|
2020-04-29 16:44:27 +01:00
|
|
|
const appProxy = AppProxy.getInstance('TestApp');
|
2020-03-20 08:58:26 +00:00
|
|
|
|
2021-10-04 16:50:07 +01:00
|
|
|
should.exist(appProxy.helperService);
|
|
|
|
should.exist(appProxy.helperService.registerAlias);
|
|
|
|
should.exist(appProxy.helperService.registerDir);
|
|
|
|
should.exist(appProxy.helperService.registerHelper);
|
2020-03-20 08:58:26 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('allows helper registration', function () {
|
2021-10-04 16:50:07 +01:00
|
|
|
const registerSpy = sinon.stub(helpers, 'registerHelper');
|
2020-04-29 16:44:27 +01:00
|
|
|
const appProxy = AppProxy.getInstance('TestApp');
|
2020-03-20 08:58:26 +00:00
|
|
|
|
2021-10-04 16:50:07 +01:00
|
|
|
appProxy.helperService.registerHelper('myTestHelper', sinon.stub().returns('test result'));
|
2020-03-20 08:58:26 +00:00
|
|
|
|
|
|
|
registerSpy.called.should.equal(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|