mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
f08a55c21f
refs: https://github.com/TryGhost/Team/issues/856 refs: https://github.com/TryGhost/Team/issues/756 - The .test.js extension is better than _spec.js as it's more obvious that it's an extension - It also meaans we can use the --extension parameter in mocha, which should result in a better default behaviour for `yarn test` - It also highlights that some of our tests were named incorrectly and were not (and still will not be) run (see https://github.com/TryGhost/Team/issues/856) - Note: even with this change, `yarn test` is throwing errors, I believe because of this issue https://github.com/TryGhost/Team/issues/756
72 lines
2.2 KiB
JavaScript
72 lines
2.2 KiB
JavaScript
const should = require('should');
|
|
const _ = require('lodash');
|
|
const configUtils = require('../../../../core/shared/config/utils');
|
|
|
|
let fakeConfig = {};
|
|
let fakeNconf = {};
|
|
let changedKey = [];
|
|
|
|
describe('Config Utils', function () {
|
|
describe('makePathsAbsolute', function () {
|
|
beforeEach(function () {
|
|
changedKey = [];
|
|
|
|
fakeNconf.get = (key) => {
|
|
key = key.replace(':', '');
|
|
return _.get(fakeConfig, key);
|
|
};
|
|
fakeNconf.set = function (key, value) {
|
|
changedKey.push([key, value]);
|
|
};
|
|
});
|
|
|
|
it('ensure we change paths only', function () {
|
|
fakeConfig.database = {
|
|
client: 'mysql',
|
|
connection: {
|
|
filename: 'content/data/ghost.db'
|
|
}
|
|
};
|
|
|
|
configUtils.makePathsAbsolute(fakeNconf, fakeConfig.database, 'database');
|
|
|
|
changedKey.length.should.eql(1);
|
|
changedKey[0][0].should.eql('database:connection:filename');
|
|
changedKey[0][1].should.not.eql('content/data/ghost.db');
|
|
});
|
|
|
|
it('ensure it skips non strings', function () {
|
|
fakeConfig.database = {
|
|
test: 10
|
|
};
|
|
|
|
configUtils.makePathsAbsolute(fakeNconf, fakeConfig.database, 'database');
|
|
changedKey.length.should.eql(0);
|
|
});
|
|
|
|
it('ensure we don\'t change absolute paths', function () {
|
|
fakeConfig.database = {
|
|
client: 'mysql',
|
|
connection: {
|
|
filename: '/content/data/ghost.db'
|
|
}
|
|
};
|
|
|
|
configUtils.makePathsAbsolute(fakeNconf, fakeConfig.database, 'database');
|
|
changedKey.length.should.eql(0);
|
|
});
|
|
|
|
it('match paths on windows', function () {
|
|
fakeConfig.database = {
|
|
filename: 'content\\data\\ghost.db'
|
|
|
|
};
|
|
|
|
configUtils.makePathsAbsolute(fakeNconf, fakeConfig.database, 'database');
|
|
changedKey.length.should.eql(1);
|
|
changedKey[0][0].should.eql('database:filename');
|
|
changedKey[0][1].should.not.eql('content\\data\\ghost.db');
|
|
});
|
|
});
|
|
});
|