const models = require('vn-loopback/server/server').models; describe('Model rewriteDbError()', () => { it('should extend rewriteDbError properties to any model passed', () => { const exampleModel = models.ItemTag; expect(exampleModel.rewriteDbError).toBeDefined(); }); it('should handle a duplicated warehouse error', async() => { const tx = await models.Ticket.beginTransaction({}); let error; try { const options = {transaction: tx}; const itemTag = {itemFk: 1, tagFk: 56, value: 'Ranged weapon', priority: 1}; await models.ItemTag.create(itemTag, options); await tx.rollback(); } catch (e) { await tx.rollback(); error = e; } expect(error.message).toEqual(`The tag can't be repeated`); }); });