0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/core/test/unit/errors_spec.js
kirrg001 d7c8da7ee8 small error improvements
no issue

- in Ignition we have added keeping the original stack, i copied it over
- i would like to use Ignition in Ghost asap to avoid having inconsistencies
- added support for options.err is a string
- extend tests
2016-11-09 09:22:33 +01:00

79 lines
2.3 KiB
JavaScript

var errors = require('../../server/errors'),
should = require('should');
should.equal(true, true);
describe('Errors', function () {
it('Ensure we inherit from Error', function () {
var ghostError = new 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 errors.GhostError({err: someError});
ghostError.message.should.eql(someError.message);
ghostError.context.should.eql(someError.context);
ghostError.help.should.eql(someError.help);
});
it('has nested object', function () {
var someError = new Error(), ghostError;
someError.message = 'test';
someError.obj = {
a: 'b'
};
ghostError = new errors.GhostError({
err: someError
});
ghostError.message.should.eql(someError.message);
ghostError.obj.should.eql(someError.obj);
});
it('with custom attribute', function () {
var someError = new Error(), ghostError;
someError.message = 'test';
someError.context = 'test';
ghostError = new errors.GhostError({
err: someError,
context: 'context'
});
ghostError.message.should.eql(someError.message);
ghostError.context.should.eql('test');
});
it('with custom attribute', function () {
var someError = new Error(), ghostError;
someError.message = 'test';
ghostError = new errors.GhostError({
err: someError,
context: 'context'
});
ghostError.message.should.eql(someError.message);
ghostError.context.should.eql('context');
});
it('error is string', function () {
var ghostError = new errors.GhostError({
err: 'string'
});
ghostError.message.should.eql('string');
});
});
});