mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
- The helper registration code is "framework" code and very specific - At the moment the "theme engine" is full of lots of disparate theme related stuff - I'm trying to make the frontend framework code clearer and also expand it to make it more useful - The helper system now also exposes 3 methods allowing you to register a directory, a helper or an alias - I've updated the codebase to use these both for our core helpers and for "apps"
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
const should = require('should');
|
|
const sinon = require('sinon');
|
|
const helpers = require('../../../../core/frontend/services/helpers');
|
|
const AppProxy = require('../../../../core/frontend/services/apps/proxy');
|
|
const routing = require('../../../../core/frontend/services/routing');
|
|
|
|
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 () {
|
|
const appProxy = AppProxy.getInstance('TestApp');
|
|
|
|
should.exist(appProxy.helperService);
|
|
should.exist(appProxy.helperService.registerAlias);
|
|
should.exist(appProxy.helperService.registerDir);
|
|
should.exist(appProxy.helperService.registerHelper);
|
|
});
|
|
|
|
it('allows helper registration', function () {
|
|
const registerSpy = sinon.stub(helpers, 'registerHelper');
|
|
const appProxy = AppProxy.getInstance('TestApp');
|
|
|
|
appProxy.helperService.registerHelper('myTestHelper', sinon.stub().returns('test result'));
|
|
|
|
registerSpy.called.should.equal(true);
|
|
});
|
|
});
|
|
});
|