const models = require('vn-loopback/server/server').models; describe('Item editFixedPrice()', () => { it('should change the value of a given column for the selected buys', async() => { const tx = await models.FixedPrice.beginTransaction({}); const options = {transaction: tx}; try { const ctx = { args: { search: '1' }, req: {accessToken: {userId: 1}} }; const [original] = await models.FixedPrice.filter(ctx, null, options); const field = 'rate2'; const newValue = 99; const lines = [{itemFk: original.itemFk, id: original.id}]; await models.FixedPrice.editFixedPrice(ctx, field, newValue, lines, null, options); const [result] = await models.FixedPrice.filter(ctx, null, options); expect(result[field]).toEqual(newValue); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); it('should change the value of a given column for filter', async() => { const tx = await models.FixedPrice.beginTransaction({}); const options = {transaction: tx}; try { const filter = {where: {'it.categoryFk': 1}}; const ctx = { args: { filter: filter }, req: {accessToken: {userId: 1}} }; const field = 'rate2'; const newValue = 88; await models.FixedPrice.editFixedPrice(ctx, field, newValue, null, filter.where, options); const [result] = await models.FixedPrice.filter(ctx, filter, options); expect(result[field]).toEqual(newValue); await tx.rollback(); } catch (e) { await tx.rollback(); throw e; } }); });