From f9025bef984b67c9b5592401baaf2f9d3fe9c471 Mon Sep 17 00:00:00 2001 From: Bernat Exposito Domenech Date: Thu, 11 Jun 2020 10:37:40 +0200 Subject: [PATCH] delete test --- modules/client/back/models/client.js | 9 +-- .../client/back/models/specs/client.spec.js | 57 ------------------- 2 files changed, 2 insertions(+), 64 deletions(-) delete mode 100644 modules/client/back/models/specs/client.spec.js diff --git a/modules/client/back/models/client.js b/modules/client/back/models/client.js index d51f16019..8ceff0c2a 100644 --- a/modules/client/back/models/client.js +++ b/modules/client/back/models/client.js @@ -222,18 +222,13 @@ module.exports = Self => { app.on('started', function() { let account = app.models.Account; + account.observe('before save', async ctx => { if (ctx.isNewInstance) return; ctx.hookState.oldInstance = JSON.parse(JSON.stringify(ctx.currentInstance)); }); + account.observe('after save', async ctx => { - console.log('--------------asdajdgsaysdgahsdkasgdagdsjhagdkadasda--------------'); - console.log('--------------asdajdgsaysdgahsdkasgdagdsjhagdkadasda--------------'); - console.log('--------------asdajdgsaysdgahsdkasgdagdsjhagdkadasda--------------'); - console.log('--------------asdajdgsaysdgahsdkasgdagdsjhagdkadasda--------------'); - console.log('--------------asdajdgsaysdgahsdkasgdagdsjhagdkadasda--------------'); - console.log('--------------asdajdgsaysdgahsdkasgdagdsjhagdkadasda--------------'); - console.log('--------------asdajdgsaysdgahsdkasgdagdsjhagdkadasda--------------'); let changes = ctx.data || ctx.instance; if (!ctx.isNewInstance && changes) { let oldData = ctx.hookState.oldInstance; diff --git a/modules/client/back/models/specs/client.spec.js b/modules/client/back/models/specs/client.spec.js deleted file mode 100644 index 0ce70b4ae..000000000 --- a/modules/client/back/models/specs/client.spec.js +++ /dev/null @@ -1,57 +0,0 @@ -const app = require('vn-loopback/server/server'); - -fdescribe('loopback model client', () => { - const accountId = 101; - let originalValue; - afterAll(async done => { - // await originalValue.save(); - - done(); - }); - - describe('observe()', () => { - it('should log when we update the account model', async() => { - originalValue = await app.models.Account.findById(accountId); - let account = await app.models.Account.findById(accountId); - - await account.updateAttribute('name', 'updatingName'); - let clientLog = await app.models.ClientLog.find({where: {originFk: accountId}}); - console.log('clientLog', clientLog); - // let logs = await app.models.ClientLog.find({fields: ['id', 'newInstance']}); - - // let m3Log = logs.filter(log => { - // return log.newInstance.m3 === 1.9; - // }); - // logIdToDestroy = m3Log[0].id; - - expect(clientLog).toBe(); - }); - - xit('should set isEqualizated to true of a given Client to trigger any new address to have it', async() => { - let client = await app.models.Client.findById(clientId); - - expect(client.isEqualizated).toBeFalsy(); - - await client.updateAttribute('isEqualizated', true); - - let newAddress = await app.models.Address.create({ - clientFk: clientId, - agencyModeFk: 5, - city: 'here', - isActive: true, - mobile: '555555555', - nickname: 'Test address', - phone: '555555555', - postalCode: '46000', - provinceFk: 1, - street: 'Test address', - incotermsFk: 'FAS', - customsAgentFk: 1 - }); - - expect(newAddress.isEqualizated).toBeTruthy(); - - createdAddressId = newAddress.id; - }); - }); -});