adapted a test that was using the niches model
This commit is contained in:
parent
5ca795adb3
commit
0b331c4026
|
@ -1,19 +1,29 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Model rewriteDbError()', () => {
|
describe('Model rewriteDbError()', () => {
|
||||||
it('should extend rewriteDbError properties to any model passed', () => {
|
it('should extend rewriteDbError properties to any model passed', () => {
|
||||||
let exampleModel = app.models.ItemNiche;
|
const exampleModel = models.ItemTag;
|
||||||
|
|
||||||
expect(exampleModel.rewriteDbError).toBeDefined();
|
expect(exampleModel.rewriteDbError).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should handle a duplicated warehouse error', async() => {
|
it('should handle a duplicated warehouse error', async() => {
|
||||||
let itemNiche = {itemFk: 1, warehouseFK: 1, code: 'A11'};
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
await app.models.ItemNiche.create(itemNiche).catch(e => {
|
|
||||||
|
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;
|
error = e;
|
||||||
}).finally(() => {
|
}
|
||||||
expect(error.message).toEqual(`The warehouse can't be repeated`);
|
|
||||||
});
|
expect(error.message).toEqual(`The tag can't be repeated`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue