2019-01-24 08:08:28 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
2018-09-18 08:11:51 +00:00
|
|
|
|
|
|
|
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`);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|