0
Fork 0
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:
Vikas Potluri 2020-06-01 16:06:50 -05:00 committed by GitHub
parent 310ecd37c4
commit 935acfdb88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 87 deletions

View file

@ -28,9 +28,10 @@
"ci:regression": "grunt test-regression --verbose",
"setup": "yarn install && knex-migrator init && grunt symlink && grunt init || true",
"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: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",
"fixmodulenotdefined": "yarn cache clean && cd core/client && rm -rf node_modules tmp dist && yarn && cd ../../"
},

View file

@ -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/);
});
});
});

View file

@ -2,7 +2,7 @@ const should = require('should');
const path = require('path');
const rewire = require('rewire');
const _ = require('lodash');
const configUtils = require('../../utils/configUtils');
const configUtils = require('../../../utils/configUtils');
describe('Config', function () {
before(function () {
@ -22,7 +22,7 @@ describe('Config', function () {
beforeEach(function () {
originalEnv = _.clone(process.env);
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
// required config properties are available
@ -38,8 +38,8 @@ describe('Config', function () {
process.env.database__client = 'test';
customConfig = config.loadNconf({
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
});
customConfig.get('database:client').should.eql('test');
@ -50,8 +50,8 @@ describe('Config', function () {
process.argv[2] = '--database:client=stronger';
customConfig = config.loadNconf({
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
});
customConfig.get('database:client').should.eql('stronger');
@ -62,8 +62,8 @@ describe('Config', function () {
process.argv[2] = '--paths:corePath=try-to-override';
customConfig = config.loadNconf({
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
});
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 () {
customConfig = config.loadNconf({
baseConfigPath: path.join(__dirname, '../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../utils/fixtures/config')
baseConfigPath: path.join(__dirname, '../../../utils/fixtures/config'),
customConfigPath: path.join(__dirname, '../../../utils/fixtures/config')
});
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 () {
const pathConfig = configUtils.config.get('paths');
const appRoot = path.resolve(__dirname, '../../../');
const appRoot = path.resolve(__dirname, '../../../../');
pathConfig.should.have.property('appRoot', appRoot);
});

View file

@ -1,5 +1,5 @@
const should = require('should');
const configUtils = require('../../../core/shared/config/utils');
const configUtils = require('../../../../core/shared/config/utils');
describe('UNIT: Config utils', function () {
describe('makePathsAbsolute', function () {