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

20 lines
666 B
JavaScript
Raw Normal View History

const app = require('../../../../../item/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`);
});
});
});