From 7fbbe2fddd58e964505c0c77538cca9e20de69b3 Mon Sep 17 00:00:00 2001 From: carlosjr Date: Fri, 17 Dec 2021 15:14:31 +0100 Subject: [PATCH] ctx was poluted by tests --- .../back/methods/order/specs/filter.spec.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/modules/order/back/methods/order/specs/filter.spec.js b/modules/order/back/methods/order/specs/filter.spec.js index 84e293840..53b666c10 100644 --- a/modules/order/back/methods/order/specs/filter.spec.js +++ b/modules/order/back/methods/order/specs/filter.spec.js @@ -8,13 +8,14 @@ describe('order filter()', () => { }; it('should call the filter method with a basic search', async() => { + const myCtx = Object.assign({}, ctx); const tx = await models.Order.beginTransaction({}); try { const options = {transaction: tx}; const filter = {where: {'o.id': 2}}; - const result = await models.Order.filter(ctx, filter, options); + const result = await models.Order.filter(myCtx, filter, options); const orderId = result[0].id; expect(orderId).toEqual(2); @@ -27,13 +28,14 @@ describe('order filter()', () => { }); it('should call the filter method with a single advanced search', async() => { + const myCtx = Object.assign({}, ctx); const tx = await models.Order.beginTransaction({}); try { const options = {transaction: tx}; const filter = {where: {'o.confirmed': false}}; - const result = await models.Order.filter(ctx, filter, options); + const result = await models.Order.filter(myCtx, filter, options); expect(result.length).toEqual(16); @@ -45,13 +47,14 @@ describe('order filter()', () => { }); it('should call the filter method with a complex advanced search', async() => { + const myCtx = Object.assign({}, ctx); const tx = await models.Order.beginTransaction({}); try { const options = {transaction: tx}; const filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 18}}; - const result = await models.Order.filter(ctx, filter, options); + const result = await models.Order.filter(myCtx, filter, options); expect(result.length).toEqual(9); expect(result[0].id).toEqual(7); @@ -64,14 +67,15 @@ describe('order filter()', () => { }); it('should return the orders matching the showEmpty on false', async() => { + const myCtx = Object.assign({}, ctx); const tx = await models.Order.beginTransaction({}); try { const options = {transaction: tx}; const filter = {}; - ctx.args = {showEmpty: false}; - const result = await models.Order.filter(ctx, filter, options); + myCtx.args = {showEmpty: false}; + const result = await models.Order.filter(myCtx, filter, options); const hasEmptyLines = result.some(order => { return order.total === 0; }); @@ -86,14 +90,15 @@ describe('order filter()', () => { }); it('should return the orders matching the showEmpty on true', async() => { + const myCtx = Object.assign({}, ctx); const tx = await models.Order.beginTransaction({}); try { const options = {transaction: tx}; const filter = {}; - ctx.args = {showEmpty: true}; - const result = await models.Order.filter(ctx, filter, options); + myCtx.args = {showEmpty: true}; + const result = await models.Order.filter(myCtx, filter, options); const hasEmptyLines = result.some(order => { return order.total === 0; });