mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
- move all test files from core/test to test/ - updated all imports and other references - all code inside of core/ is then application code - tests are correctly at the root level - consistent with other repos/projects Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
70 lines
2 KiB
JavaScript
70 lines
2 KiB
JavaScript
var should = require('should'),
|
|
common = require('../../../../core/server/lib/common');
|
|
|
|
describe('Errors', function () {
|
|
it('Ensure we inherit from Error', function () {
|
|
var ghostError = new common.errors.GhostError();
|
|
(ghostError instanceof Error).should.eql(true);
|
|
});
|
|
|
|
describe('Inherite from other error', function () {
|
|
it('default', function () {
|
|
var someError = new Error(), ghostError;
|
|
|
|
someError.message = 'test';
|
|
someError.context = 'test';
|
|
someError.help = 'test';
|
|
|
|
ghostError = new common.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 () {
|
|
var someError = new Error(), ghostError;
|
|
|
|
someError.obj = {
|
|
a: 'b'
|
|
};
|
|
|
|
ghostError = new common.errors.GhostError({
|
|
err: someError
|
|
});
|
|
|
|
ghostError.obj.should.eql(someError.obj);
|
|
});
|
|
|
|
it('with custom attribute', function () {
|
|
var someError = new Error(), ghostError;
|
|
|
|
someError.context = 'test';
|
|
|
|
ghostError = new common.errors.GhostError({
|
|
err: someError,
|
|
context: 'context'
|
|
});
|
|
|
|
ghostError.context.should.eql('test');
|
|
});
|
|
|
|
it('with custom attribute', function () {
|
|
var someError = new Error(), ghostError;
|
|
|
|
ghostError = new common.errors.GhostError({
|
|
err: someError,
|
|
message: 'test'
|
|
});
|
|
|
|
ghostError.message.should.eql('test');
|
|
});
|
|
|
|
it('error is string', function () {
|
|
var ghostError = new common.errors.GhostError({
|
|
err: 'string'
|
|
});
|
|
|
|
ghostError.stack.should.match(/Error: string/);
|
|
});
|
|
});
|
|
});
|