describe('@PackageNotDefinedError', () => { it('should throw PackageNotDefinedError if no pkg definition is provided', () => { const def = { config: { main: { paths: { root: __dirname } } } } assert.throws(() => new FabrixApp(def), lib.PackageNotDefinedError) }) })
it('should throw an error when attempting to set a value after frozen', () => { const config = new lib.Configuration(_.cloneDeep(testConfig), {NODE_ENV: 'test'}) config.freeze() assert.throws(() => config.set('customObject.string', 'b'), lib.IllegalAccessError) // TODO re-enable // assert.throws(() => config.customObject.string = 'c', lib.IllegalAccessError) // assert.throws(() => config.customObject['string'] = 'c', lib.IllegalAccessError) })
// TODO: resources will be changing to an Object in v2.0 it('should throw error on incorrectly configured main.resources', () => { const def = { pkg: { }, api: { }, config: { main: { resources: {} } } } assert.throws(() => new FabrixApp(def), Error) })
it('should freeze config object after spools are loaded', () => { const def = { pkg: { }, api: { }, config: { main: { spools: [ Testspool ] }, foo: 'bar' } } const app = new FabrixApp(def) assert.equal(app.config.get('foo'), 'bar') return app.start().then(() => { assert.equal(app.config.get('foo'), 'bar') assert.throws(() => app.config.set('foo', 1), Error) return app.stop() }) })
}) it('will error if instantiated directly', () => { assert.throws(() => new DatastoreSpool(global.app), Error) }) }) }) it('will error if instantiated directly', () => { assert.throws(() => new MiscSpool(global.app), Error) }) }) }) it('will error if instantiated directly', () => { assert.throws(() => new ServerSpool(global.app), Error) }) }) }) it('will error if instantiated directly', () => { assert.throws(() => new SystemSpool(global.app), Error) }) }) }) it('will error if instantiated directly', () => { assert.throws(() => new ToolSpool(global.app), Error) }) })
assert.throws(() => lib.Core.handlePromiseRejection(new Error('Promise Rejection Test')), Error) }) })
describe('errors', () => { it('should require "app" argument to constructor', () => { assert.throws(() => new Policy(), Error) }) })
describe('errors', () => { it('should require "app" argument to constructor', () => { assert.throws(() => new Model(), Error) }) })
describe('@ApiNotDefinedError', () => { it('should throw ApiNotDefinedError if no api definition is provided', () => { const def = { pkg: { }, config: { main: { paths: { root: __dirname } } } } assert.throws(() => new FabrixApp(def), lib.ApiNotDefinedError) }) })
describe('errors', () => { it('should require "app" argument to constructor', () => { assert.throws(() => new Service(), Error) }) })
describe('@SpoolError', () => { it('should throw PackageNotDefinedError if no pkg definition is provided', () => { const def = { api: { }, pkg: { }, config: { main: { spools: [ class Failspool extends Spool { constructor (app) { super(app) } } ] } } } assert.throws(() => new FabrixApp(def), lib.SpoolError) }) })
describe('errors', () => { it('should require "app" argument to constructor', () => { assert.throws(() => new Controller(), Error) }) })
it('should require "app" argument to constructor', () => { assert.throws(() => new FabrixApp(), RangeError) })