#1184 Propagar done en afterAll() de los test back
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-03-01 11:50:26 +01:00
parent ec6364490a
commit acbe9b8488
26 changed files with 100 additions and 46 deletions

View File

@ -3,10 +3,12 @@ const app = require('vn-loopback/server/server');
describe('Claim importTicketSales()', () => {
let claimEnds;
afterAll(async () => {
afterAll(async done => {
claimEnds.forEach(async line => {
await line.destroy();
});
done();
});
it('should import sales to a claim actions from an specific ticket', async() => {

View File

@ -4,8 +4,10 @@ describe('Claim Create', () => {
let newDate = new Date();
let createdClaimFk;
afterAll(async () => {
afterAll(async done => {
await app.models.Claim.destroyById(createdClaimFk);
done();
});
let newClaim = {

View File

@ -9,7 +9,7 @@ xdescribe('regularizeClaim()', () => {
let claimEnds = [];
let trashTicket;
afterAll(async () => {
afterAll(async done => {
let claim = await app.models.Claim.findById(claimFk);
await claim.updateAttributes({claimStateFk: pendentState});
await app.models.Ticket.destroyById(trashTicket.id);
@ -17,6 +17,8 @@ xdescribe('regularizeClaim()', () => {
claimEnds.forEach(async line => {
await line.destroy();
});
done();
});
it('should change claim state to resolved', async() => {

View File

@ -14,12 +14,16 @@ describe('Update Claim', () => {
observation: 'observation'
};
beforeAll(async() => {
beforeAll(async done => {
newInstance = await app.models.Claim.create(original);
done();
});
afterAll(async() => {
afterAll(async done => {
await app.models.Claim.destroyById(newInstance.id);
done();
});
it('should throw error if isSaleAssistant is false and try to modify a forbidden field', async() => {

View File

@ -4,9 +4,11 @@ describe('Address createDefaultAddress', () => {
let address;
let client;
afterAll(async() => {
afterAll(async done => {
await client.updateAttributes({defaultAddressFk: 1});
await address.destroy();
done();
});
it('should verify that client defaultAddressFk is untainted', async() => {

View File

@ -8,9 +8,11 @@ describe('Client addressesPropagateRe', () => {
await client.updateAttributes({hasToInvoiceByAddress: true});
});
afterAll(async() => {
afterAll(async done => {
await app.models.Address.update({clientFk: 101}, {isEqualizated: false});
await client.updateAttributes({hasToInvoiceByAddress: true});
done();
});
it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => {

View File

@ -3,9 +3,11 @@ const app = require('vn-loopback/server/server');
describe('Client confirmTransaction', () => {
const transactionId = 2;
afterAll(async() => {
afterAll(async done => {
await app.models.Client.rawSql(`
CALL hedera.tpvTransactionUndo(?)`, [transactionId]);
done();
});
it('should call confirmTransaction() method to mark transaction as confirmed', async() => {

View File

@ -4,13 +4,15 @@ describe('Client Create', () => {
const clientName = 'Wade';
const AccountName = 'Deadpool';
afterAll(async() => {
afterAll(async done => {
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);
done();
});
let newAccount = {

View File

@ -1,12 +1,14 @@
const app = require('vn-loopback/server/server');
describe('Client updateFiscalData', () => {
afterAll(async() => {
afterAll(async done => {
let ctxOfAdmin = {req: {accessToken: {userId: 5}}};
let validparams = {postcode: 46460};
let idWithDataChecked = 101;
await app.models.Client.updateFiscalData(ctxOfAdmin, validparams, idWithDataChecked);
done();
});
it('should return an error if the user is not administrative and the isTaxDataChecked value is true', async() => {

View File

@ -3,8 +3,10 @@ const app = require('vn-loopback/server/server');
describe('Client createWithInsurance', () => {
let classificationId;
afterAll(async() => {
afterAll(async done => {
await app.models.CreditClassification.destroyById(classificationId);
done();
});
it('should verify the classifications and insurances are untainted', async() => {
@ -24,7 +26,7 @@ describe('Client createWithInsurance', () => {
error = e;
});
expect(error.toString()).toBe("Error: ER_BAD_NULL_ERROR: Column 'client' cannot be null");
expect(error.toString()).toBe('Error: ER_BAD_NULL_ERROR: Column \'client\' cannot be null');
let classifications = await app.models.CreditClassification.find();
let insurances = await app.models.CreditInsurance.find();

View File

@ -3,8 +3,10 @@ const app = require('vn-loopback/server/server');
describe('item new()', () => {
let item;
afterAll(async() => {
afterAll(async done => {
await app.models.Item.destroyById(item.id);
done();
});
it('should create a new item, adding the name as a tag', async() => {

View File

@ -6,8 +6,10 @@ describe('regularize()', () => {
const trashAddress = 11;
let trashTicket;
afterAll(async () => {
afterAll(async done => {
await app.models.Ticket.destroyById(trashTicket.id);
done();
});
it('should create a new ticket and add a line', async() => {

View File

@ -1,10 +1,12 @@
const app = require('vn-loopback/server/server');
describe('item updateTaxes()', () => {
afterAll(async() => {
afterAll(async done => {
let taxesInFixtures = [{id: 3, taxClassFk: 1}];
await app.models.Item.updateTaxes(taxesInFixtures);
done();
});
it('should throw an error if the taxClassFk is blank', async() => {

View File

@ -2,8 +2,10 @@ const app = require('vn-loopback/server/server');
describe('order addToOrder()', () => {
let rowToDelete;
afterAll(async() => {
afterAll(async done => {
await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: 20});
done();
});
it('should add a row to a given order', async() => {

View File

@ -4,10 +4,12 @@ describe('order removes()', () => {
let row;
let newRow;
beforeAll(async() => {
beforeAll(async done => {
row = await app.models.OrderRow.findOne({where: {id: 12}});
row.id = null;
newRow = await app.models.OrderRow.create(row);
done();
});
it('should throw an error if rows property is empty', async() => {

View File

@ -4,8 +4,10 @@ let UserError = require('vn-loopback/util/user-error');
describe('order new()', () => {
let orderId;
afterAll(async() => {
afterAll(async done => {
await app.models.Order.destroyById(orderId);
done();
});
it('should throw an error if the client is frozen', async() => {

View File

@ -1,11 +1,13 @@
const app = require('vn-loopback/server/server');
describe('Order updateBasicData', () => {
afterAll(async () => {
afterAll(async done => {
let validparams = {note: null};
let orderId = 21;
await app.models.Order.updateBasicData(validparams, orderId);
done();
});
it('should return an error if the order is confirmed', async() => {

View File

@ -4,10 +4,12 @@ describe('sale removes()', () => {
let sale;
let newsale;
beforeAll(async() => {
beforeAll(async done => {
sale = await app.models.Sale.findOne({where: {id: 9}});
sale.id = null;
newsale = await app.models.Sale.create(sale);
done();
});
it('should throw an error if the ticket of the given sales is not editable', async() => {

View File

@ -1,7 +1,7 @@
const app = require('vn-loopback/server/server');
describe('sale reserve()', () => {
afterAll(async() => {
afterAll(async done => {
let params = {
sales: [
{id: 7},
@ -11,6 +11,8 @@ describe('sale reserve()', () => {
};
await app.models.Sale.reserve(params);
done();
});
it('should throw an error if the ticket can not be modified', async() => {

View File

@ -3,14 +3,18 @@ const app = require('vn-loopback/server/server');
describe('ticket changeState()', () => {
let ticket;
beforeAll(async() => {
beforeAll(async done => {
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
originalTicket.id = null;
ticket = await app.models.Ticket.create(originalTicket);
done();
});
afterAll(async() => {
afterAll(async done => {
await app.models.Ticket.destroyById(ticket.id);
done();
});
it('should throw an error if the ticket is not editable and the user isnt production', async() => {

View File

@ -11,12 +11,14 @@ describe('ticket componentUpdate()', () => {
const today = new Date();
let ticketId = 11;
beforeAll(async() => {
beforeAll(async done => {
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
firstvalueBeforeChange = componentValue.value;
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleEight);
secondvalueBeforeChange = componentValue.value;
done();
});
it('should change the agencyMode to modify the sale components value', async() => {

View File

@ -3,14 +3,18 @@ const app = require('vn-loopback/server/server');
describe('ticket deleted()', () => {
let ticket;
beforeAll(async() => {
beforeAll(async done => {
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
originalTicket.id = null;
ticket = await app.models.Ticket.create(originalTicket);
done();
});
afterAll(async() => {
afterAll(async done => {
await app.models.Ticket.destroyById(ticket.id);
done();
});
it('should make sure the ticket is not deleted yet', async() => {

View File

@ -7,8 +7,10 @@ describe('ticket new()', () => {
let today = new Date();
let ctx = {req: {accessToken: {userId: 1}}};
afterAll(async() => {
afterAll(async done => {
await app.models.Ticket.destroyById(ticket.id);
done();
});
it('should throw an error if the client is frozen', async() => {

View File

@ -3,8 +3,10 @@ const app = require('vn-loopback/server/server');
describe('ticket model TicketTracking', () => {
let ticketTrackingId;
afterAll(async() => {
afterAll(async done => {
await app.models.TicketPackaging.destroyById(ticketTrackingId);
done();
});
it('should save a ticketTraing as the quantity is greater than 0', async() => {