From 1002b39694100d46513966a76972d7654cdc7053 Mon Sep 17 00:00:00 2001 From: Bernat Date: Fri, 28 Sep 2018 08:43:00 +0200 Subject: [PATCH] refactor test #649 --- .../client/specs/createWithUser.spec.js | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/services/loopback/common/methods/client/specs/createWithUser.spec.js b/services/loopback/common/methods/client/specs/createWithUser.spec.js index d165efe99..2e43d467c 100644 --- a/services/loopback/common/methods/client/specs/createWithUser.spec.js +++ b/services/loopback/common/methods/client/specs/createWithUser.spec.js @@ -1,19 +1,24 @@ const app = require(`${servicesDir}/client/server/server`); -const restoreFixtures = require(`${servicesDir}/db/testing_fixtures`); describe('Client Create', () => { - let sqlStatements = {deletes: ` - DELETE FROM vn.address WHERE nickname = 'Wade'; - DELETE FROM vn.client WHERE name = 'Wade'; - DELETE FROM account.user WHERE name = 'Deadpool'; - `, inserts: ``, updates: ``}; + const clientName = 'Wade'; + const AccountName = 'Deadpool'; + /* beforeAll(async() => { + let address = await app.models.Address.findOne({where: {nickname: clientName}}); + let client = await app.models.Client.findOne({where: {name: clientName}}); + let account = await app.models.Account.findOne({where: {name: AccountName}}); + await app.models.Address.destroyById(address.id); + await app.models.Client.destroyById(client.id); + await app.models.Account.destroyById(account.id); + }); */ - beforeAll(() => { - restoreFixtures(sqlStatements); - }); - - afterAll(() => { - restoreFixtures(sqlStatements); + afterAll(async() => { + let address = await app.models.Address.findOne({where: {nickname: clientName}}); + let client = await app.models.Client.findOne({where: {name: clientName}}); + let account = await app.models.Account.findOne({where: {name: AccountName}}); + await app.models.Address.destroyById(address.id); + await app.models.Client.destroyById(client.id); + await app.models.Account.destroyById(account.id); }); let newAccount = {