mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-29 22:01:49 +03:00
332beaaf90
- These are simple functions that get data from config in a specific format - They are also used by the topmost part of the application - Config helpers seems like a reasonable fit to get them out of the web folder - Functions have also been renamed to try to get them to make more sense
55 lines
2.0 KiB
JavaScript
55 lines
2.0 KiB
JavaScript
const should = require('should');
|
|
const configUtils = require('../../../utils/configUtils');
|
|
|
|
describe('vhost utils', function () {
|
|
beforeEach(function () {
|
|
configUtils.set('url', 'http://ghost.blog');
|
|
});
|
|
|
|
afterEach(function () {
|
|
configUtils.restore();
|
|
});
|
|
|
|
// url = 'https://ghost.blog'
|
|
describe('without separate admin url', function () {
|
|
it('uses the default arg for both backend and frontend', function () {
|
|
configUtils.config.getBackendMountPath().should.eql(/.*/);
|
|
configUtils.config.getFrontendMountPath().should.eql(/.*/);
|
|
});
|
|
});
|
|
|
|
// url = 'https://ghost.blog'
|
|
// admin.url = 'https://admin.ghost.blog'
|
|
describe('with separate admin url', function () {
|
|
beforeEach(function () {
|
|
configUtils.set('admin:url', 'https://admin.ghost.blog');
|
|
});
|
|
|
|
it('should use admin url and inverse as args', function () {
|
|
configUtils.config.getBackendMountPath().should.eql('admin.ghost.blog');
|
|
configUtils.config.getFrontendMountPath().should.eql(/^(?!admin\.ghost\.blog).*/);
|
|
});
|
|
|
|
it('should have regex that excludes admin traffic on front-end', function () {
|
|
const frontendRegex = configUtils.config.getFrontendMountPath();
|
|
|
|
frontendRegex.test('localhost').should.be.true();
|
|
frontendRegex.test('ghost.blog').should.be.true();
|
|
frontendRegex.test('admin.ghost.blog').should.be.false();
|
|
});
|
|
});
|
|
|
|
// url = 'http://ghost.blog'
|
|
// admin.url = 'https://ghost.blog'
|
|
describe('with separate admin protocol', function () {
|
|
beforeEach(function () {
|
|
configUtils.set('admin:url', 'https://ghost.blog');
|
|
});
|
|
|
|
it('should mount and assign correct routes', function () {
|
|
configUtils.config.getBackendMountPath().should.eql(/.*/);
|
|
configUtils.config.getFrontendMountPath().should.eql(/.*/);
|
|
});
|
|
});
|
|
});
|