20 lines
659 B
JavaScript
20 lines
659 B
JavaScript
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: 'A11'};
|
|
let error;
|
|
await app.models.ItemNiche.create(itemNiche).catch(e => {
|
|
error = e;
|
|
}).finally(() => {
|
|
expect(error.message).toEqual(`The warehouse can't be repeated`);
|
|
});
|
|
});
|
|
});
|