refactor test #649

This commit is contained in:
Bernat 2018-09-28 08:43:00 +02:00
parent 7a0dad9db3
commit 1002b39694
1 changed files with 17 additions and 12 deletions

View File

@ -1,19 +1,24 @@
const app = require(`${servicesDir}/client/server/server`); const app = require(`${servicesDir}/client/server/server`);
const restoreFixtures = require(`${servicesDir}/db/testing_fixtures`);
describe('Client Create', () => { describe('Client Create', () => {
let sqlStatements = {deletes: ` const clientName = 'Wade';
DELETE FROM vn.address WHERE nickname = 'Wade'; const AccountName = 'Deadpool';
DELETE FROM vn.client WHERE name = 'Wade'; /* beforeAll(async() => {
DELETE FROM account.user WHERE name = 'Deadpool'; let address = await app.models.Address.findOne({where: {nickname: clientName}});
`, inserts: ``, updates: ``}; 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(() => { afterAll(async() => {
restoreFixtures(sqlStatements); 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}});
afterAll(() => { await app.models.Address.destroyById(address.id);
restoreFixtures(sqlStatements); await app.models.Client.destroyById(client.id);
await app.models.Account.destroyById(account.id);
}); });
let newAccount = { let newAccount = {