salix/loopback/common/methods/vn-model/specs/rewriteDbError.spec.js

20 lines
658 B
JavaScript
Raw Normal View History

2019-01-24 08:08:28 +00:00
const app = require('vn-loopback/server/server');
describe('Model rewriteDbError()', () => {
it('should extend rewriteDbError properties to any model passed', () => {
let exampleModel = app.models.ItemNiche;
expect(exampleModel.rewriteDbError).toBeDefined();
});
it('should handle a duplicated warehouse error', async() => {
let itemNiche = {itemFk: 1, warehouseFK: 1, code: 'A1'};
let error;
await app.models.ItemNiche.create(itemNiche).catch(e => {
error = e;
}).finally(() => {
expect(error.message).toEqual(`The warehouse can't be repeated`);
});
});
});