From d336fd0eb195b1bf061265436bd12e390a26fb51 Mon Sep 17 00:00:00 2001 From: Joan Sanchez Date: Thu, 28 Feb 2019 10:17:09 +0100 Subject: [PATCH] fixed address --- .../client/specs/createWithUser.spec.js | 4 ++- .../client/back/models/specs/address.spec.js | 26 +++---------------- 2 files changed, 6 insertions(+), 24 deletions(-) diff --git a/modules/client/back/methods/client/specs/createWithUser.spec.js b/modules/client/back/methods/client/specs/createWithUser.spec.js index 0399606c4..7c3f80f44 100644 --- a/modules/client/back/methods/client/specs/createWithUser.spec.js +++ b/modules/client/back/methods/client/specs/createWithUser.spec.js @@ -18,7 +18,9 @@ describe('Client Create', () => { email: 'Deadpool@marvel.com', fi: '16195279J', name: 'Wade', - socialName: 'Deadpool Marvel' + socialName: 'Deadpool Marvel', + street: 'Wall Street', + city: 'New York' }; it(`should not find Deadpool as he's not created yet`, async() => { diff --git a/modules/client/back/models/specs/address.spec.js b/modules/client/back/models/specs/address.spec.js index 67e0e8e50..16beaa10f 100644 --- a/modules/client/back/models/specs/address.spec.js +++ b/modules/client/back/models/specs/address.spec.js @@ -3,14 +3,13 @@ const app = require('vn-loopback/server/server'); describe('loopback model address', () => { let createdAddressId; - afterAll(async() => { - let address = await app.models.Address.findById(1); + afterAll(async done => { let client = await app.models.Client.findById(101); - await address.updateAttribute('isDefaultAddress', true); await app.models.Address.destroyById(createdAddressId); - await client.updateAttribute('isEqualizated', false); + + done(); }); describe('observe()', () => { @@ -28,24 +27,6 @@ describe('loopback model address', () => { expect(error).toBeDefined(); }); - it('should set isDefaultAddress to false of all the addresses for a given client', async() => { - let previousDefaultAddress = await app.models.Address.findById(1); - - expect(previousDefaultAddress.isDefaultAddress).toBeTruthy(); - - let address = await app.models.Address.findById(121); - - expect(address.isDefaultAddress).toBeFalsy(); - - let defaultAddress = await address.updateAttribute('isDefaultAddress', true); - - expect(defaultAddress.isDefaultAddress).toBeTruthy(); - - let noLongerDefaultAddress = await app.models.Address.findById(1); - - expect(noLongerDefaultAddress.isDefaultAddress).toBeFalsy(); - }); - it('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(101); @@ -58,7 +39,6 @@ describe('loopback model address', () => { agencyModeFk: 5, city: 'here', isActive: true, - isDefaultAddress: false, mobile: '555555555', nickname: 'Test address', phone: '555555555',