mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
Updated tests locations and added linting of core/shared (#11872)
* 🔥 removed duplicate error tests
* add lint:shared package script, and updated lint to run it as well
* moved test/unit/config to test/unit/shared/config
This commit is contained in:
parent
310ecd37c4
commit
935acfdb88
4 changed files with 14 additions and 87 deletions
|
@ -28,9 +28,10 @@
|
||||||
"ci:regression": "grunt test-regression --verbose",
|
"ci:regression": "grunt test-regression --verbose",
|
||||||
"setup": "yarn install && knex-migrator init && grunt symlink && grunt init || true",
|
"setup": "yarn install && knex-migrator init && grunt symlink && grunt init || true",
|
||||||
"lint:server": "eslint --ignore-path .eslintignore 'core/server/**/*.js' 'core/*.js' '*.js'",
|
"lint:server": "eslint --ignore-path .eslintignore 'core/server/**/*.js' 'core/*.js' '*.js'",
|
||||||
|
"lint:shared": "eslint --ignore-path .eslintignore 'core/shared/**/*.js'",
|
||||||
"lint:frontend": "eslint --ignore-path .eslintignore 'core/frontend/**/*.js'",
|
"lint:frontend": "eslint --ignore-path .eslintignore 'core/frontend/**/*.js'",
|
||||||
"lint:test": "eslint -c test/.eslintrc.json --ignore-path test/.eslintignore 'test/**/*.js'",
|
"lint:test": "eslint -c test/.eslintrc.json --ignore-path test/.eslintignore 'test/**/*.js'",
|
||||||
"lint": "yarn lint:server && yarn lint:frontend && yarn lint:test",
|
"lint": "yarn lint:server && yarn lint:shared && yarn lint:frontend && yarn lint:test",
|
||||||
"posttest": "yarn lint",
|
"posttest": "yarn lint",
|
||||||
"fixmodulenotdefined": "yarn cache clean && cd core/client && rm -rf node_modules tmp dist && yarn && cd ../../"
|
"fixmodulenotdefined": "yarn cache clean && cd core/client && rm -rf node_modules tmp dist && yarn && cd ../../"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
const should = require('should');
|
|
||||||
const errors = require('@tryghost/errors');
|
|
||||||
|
|
||||||
describe('Errors', function () {
|
|
||||||
it('Ensure we inherit from Error', function () {
|
|
||||||
const ghostError = new errors.GhostError();
|
|
||||||
(ghostError instanceof Error).should.eql(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Inherite from other error', function () {
|
|
||||||
it('default', function () {
|
|
||||||
const someError = new Error();
|
|
||||||
let ghostError;
|
|
||||||
|
|
||||||
someError.message = 'test';
|
|
||||||
someError.context = 'test';
|
|
||||||
someError.help = 'test';
|
|
||||||
|
|
||||||
ghostError = new errors.GhostError({err: someError});
|
|
||||||
ghostError.stack.should.match(/Error: test/);
|
|
||||||
ghostError.context.should.eql(someError.context);
|
|
||||||
ghostError.help.should.eql(someError.help);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('has nested object', function () {
|
|
||||||
const someError = new Error();
|
|
||||||
let ghostError;
|
|
||||||
|
|
||||||
someError.obj = {
|
|
||||||
a: 'b'
|
|
||||||
};
|
|
||||||
|
|
||||||
ghostError = new errors.GhostError({
|
|
||||||
err: someError
|
|
||||||
});
|
|
||||||
|
|
||||||
ghostError.obj.should.eql(someError.obj);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with custom attribute', function () {
|
|
||||||
const someError = new Error();
|
|
||||||
let ghostError;
|
|
||||||
|
|
||||||
someError.context = 'test';
|
|
||||||
|
|
||||||
ghostError = new errors.GhostError({
|
|
||||||
err: someError,
|
|
||||||
context: 'context'
|
|
||||||
});
|
|
||||||
|
|
||||||
ghostError.context.should.eql('test');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('with custom attribute', function () {
|
|
||||||
const someError = new Error();
|
|
||||||
let ghostError;
|
|
||||||
|
|
||||||
ghostError = new errors.GhostError({
|
|
||||||
err: someError,
|
|
||||||
message: 'test'
|
|
||||||
});
|
|
||||||
|
|
||||||
ghostError.message.should.eql('test');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('error is string', function () {
|
|
||||||
const ghostError = new errors.GhostError({
|
|
||||||
err: 'string'
|
|
||||||
});
|
|
||||||
|
|
||||||
ghostError.stack.should.match(/Error: string/);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -2,7 +2,7 @@ const should = require('should');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const rewire = require('rewire');
|
const rewire = require('rewire');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const configUtils = require('../../utils/configUtils');
|
const configUtils = require('../../../utils/configUtils');
|
||||||
|
|
||||||
describe('Config', function () {
|
describe('Config', function () {
|
||||||
before(function () {
|
before(function () {
|
||||||
|
@ -22,7 +22,7 @@ describe('Config', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
originalEnv = _.clone(process.env);
|
originalEnv = _.clone(process.env);
|
||||||
originalArgv = _.clone(process.argv);
|
originalArgv = _.clone(process.argv);
|
||||||
config = rewire('../../../core/shared/config');
|
config = rewire('../../../../core/shared/config');
|
||||||
|
|
||||||
// we manually call `loadConf` in the tests and we need to ensure that the minimum
|
// we manually call `loadConf` in the tests and we need to ensure that the minimum
|
||||||
// required config properties are available
|
// required config properties are available
|
||||||
|
@ -38,8 +38,8 @@ describe('Config', function () {
|
||||||
process.env.database__client = 'test';
|
process.env.database__client = 'test';
|
||||||
|
|
||||||
customConfig = config.loadNconf({
|
customConfig = config.loadNconf({
|
||||||
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
|
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
|
||||||
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
|
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
|
||||||
});
|
});
|
||||||
|
|
||||||
customConfig.get('database:client').should.eql('test');
|
customConfig.get('database:client').should.eql('test');
|
||||||
|
@ -50,8 +50,8 @@ describe('Config', function () {
|
||||||
process.argv[2] = '--database:client=stronger';
|
process.argv[2] = '--database:client=stronger';
|
||||||
|
|
||||||
customConfig = config.loadNconf({
|
customConfig = config.loadNconf({
|
||||||
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
|
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
|
||||||
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
|
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
|
||||||
});
|
});
|
||||||
|
|
||||||
customConfig.get('database:client').should.eql('stronger');
|
customConfig.get('database:client').should.eql('stronger');
|
||||||
|
@ -62,8 +62,8 @@ describe('Config', function () {
|
||||||
process.argv[2] = '--paths:corePath=try-to-override';
|
process.argv[2] = '--paths:corePath=try-to-override';
|
||||||
|
|
||||||
customConfig = config.loadNconf({
|
customConfig = config.loadNconf({
|
||||||
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
|
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
|
||||||
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
|
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
|
||||||
});
|
});
|
||||||
|
|
||||||
customConfig.get('paths:corePath').should.not.containEql('try-to-override');
|
customConfig.get('paths:corePath').should.not.containEql('try-to-override');
|
||||||
|
@ -71,8 +71,8 @@ describe('Config', function () {
|
||||||
|
|
||||||
it('overrides is stronger than every other config file', function () {
|
it('overrides is stronger than every other config file', function () {
|
||||||
customConfig = config.loadNconf({
|
customConfig = config.loadNconf({
|
||||||
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
|
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
|
||||||
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
|
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
|
||||||
});
|
});
|
||||||
|
|
||||||
customConfig.get('paths:corePath').should.not.containEql('try-to-override');
|
customConfig.get('paths:corePath').should.not.containEql('try-to-override');
|
||||||
|
@ -104,7 +104,7 @@ describe('Config', function () {
|
||||||
|
|
||||||
it('should have the correct values for each key', function () {
|
it('should have the correct values for each key', function () {
|
||||||
const pathConfig = configUtils.config.get('paths');
|
const pathConfig = configUtils.config.get('paths');
|
||||||
const appRoot = path.resolve(__dirname, '../../../');
|
const appRoot = path.resolve(__dirname, '../../../../');
|
||||||
|
|
||||||
pathConfig.should.have.property('appRoot', appRoot);
|
pathConfig.should.have.property('appRoot', appRoot);
|
||||||
});
|
});
|
|
@ -1,5 +1,5 @@
|
||||||
const should = require('should');
|
const should = require('should');
|
||||||
const configUtils = require('../../../core/shared/config/utils');
|
const configUtils = require('../../../../core/shared/config/utils');
|
||||||
|
|
||||||
describe('UNIT: Config utils', function () {
|
describe('UNIT: Config utils', function () {
|
||||||
describe('makePathsAbsolute', function () {
|
describe('makePathsAbsolute', function () {
|
Loading…
Add table
Reference in a new issue