From f3558a2d2689f3f9a915637cf256febd7e636157 Mon Sep 17 00:00:00 2001 From: Bernat Date: Thu, 6 Jun 2019 09:34:45 +0200 Subject: [PATCH] #1462 updateVolume backTest --- .../methods/route/specs/updateVolume.spec.js | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/modules/route/back/methods/route/specs/updateVolume.spec.js b/modules/route/back/methods/route/specs/updateVolume.spec.js index 5a52a13a1..046240555 100644 --- a/modules/route/back/methods/route/specs/updateVolume.spec.js +++ b/modules/route/back/methods/route/specs/updateVolume.spec.js @@ -6,10 +6,13 @@ describe('route updateVolume()', () => { const ctx = {req: {accessToken: {userId: workerFk}}}; let originalRoute; let ticketRestore; + let logIdToDestroy; + afterAll(async done => { await originalRoute.updateAttributes({m3: 0.2}); await ticketRestore.updateAttributes({routeFk: 4}); + await app.models.RouteLog.destroyById(logIdToDestroy); done(); }); @@ -30,15 +33,15 @@ describe('route updateVolume()', () => { expect(updatedRoute.m3).not.toEqual(originalRoute.m3); }); - // 1462 - xit('should confirm the change is logged ', async() => { - let instanceValue = {m3: 0.3}; - let filterValue = JSON.stringify(instanceValue); - let filter = {where: {newInstance: filterValue}}; - console.log(filter); - let routeLog = await app.models.RouteLog.find(filter); - console.log(routeLog); - expect(routeLog.length).toBeGreaterThan(0); + it('should confirm the change is logged', async() => { + let instanceValue = {m3: 0.3}; + let logs = await app.models.RouteLog.find({fields: ['id', 'newInstance']}); + let m3Log = logs.filter(log => { + return log.newInstance.m3 === instanceValue.m3; + }); + logIdToDestroy = m3Log[0].id; + + expect(m3Log.length).toEqual(1); }); });