UNPKG

mongoose-data-seed

Version:

Seed mongodb with data using mongoose models

39 lines (29 loc) 1.03 kB
import test from 'ava'; import InstallerError from './installer-error'; test('should create error', t => { const error = new InstallerError(); t.is(error.name, 'InstallerError'); t.is(error.type, ''); t.deepEqual(error.payload, { error: {} }); }); test('should create error with type', t => { const type = 'some-type'; const error = new InstallerError({ type }); t.is(error.name, 'InstallerError'); t.is(error.type, type); t.deepEqual(error.payload, { error: {} }); }); test('should create error with payload', t => { const payload = { some: 'payload' }; const error = new InstallerError({ payload }); t.is(error.name, 'InstallerError'); t.is(error.type, ''); t.deepEqual(error.payload, { ...payload, error: {} }); }); test('should create error with inner error', t => { const innerError = new Error('some-error'); const error = new InstallerError({ error: innerError }); t.is(error.name, 'InstallerError'); t.is(error.type, ''); t.deepEqual(error.payload, { error: innerError }); });