This commit is contained in:
parent
ec6364490a
commit
acbe9b8488
|
@ -8,7 +8,7 @@ describe('Model crud()', () => {
|
||||||
expect(ItemBarcode.crud).toBeDefined();
|
expect(ItemBarcode.crud).toBeDefined();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new instance', async () => {
|
it('should create a new instance', async() => {
|
||||||
let data = {code: '500', itemFk: '1'};
|
let data = {code: '500', itemFk: '1'};
|
||||||
let creates = [data];
|
let creates = [data];
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ describe('Model crud()', () => {
|
||||||
expect(instance.code).toEqual('500');
|
expect(instance.code).toEqual('500');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the instance', async () => {
|
it('should update the instance', async() => {
|
||||||
let updates = [{
|
let updates = [{
|
||||||
where: {id: insertId},
|
where: {id: insertId},
|
||||||
data: {code: '501', itemFk: 1}
|
data: {code: '501', itemFk: 1}
|
||||||
|
@ -32,7 +32,7 @@ describe('Model crud()', () => {
|
||||||
expect(instance.code).toEqual('501');
|
expect(instance.code).toEqual('501');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should delete the created instance', async () => {
|
it('should delete the created instance', async() => {
|
||||||
let deletes = [insertId];
|
let deletes = [insertId];
|
||||||
await ItemBarcode.crud(deletes);
|
await ItemBarcode.crud(deletes);
|
||||||
let instance = await ItemBarcode.findById(insertId);
|
let instance = await ItemBarcode.findById(insertId);
|
||||||
|
|
|
@ -6,7 +6,7 @@ xdescribe('claimBeginning', () => {
|
||||||
let refundTicketSales;
|
let refundTicketSales;
|
||||||
let salesInsertedInClaimEnd;
|
let salesInsertedInClaimEnd;
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async() => {
|
||||||
let promises = [];
|
let promises = [];
|
||||||
promises.push(app.models.Ticket.destroyById(ticket.id));
|
promises.push(app.models.Ticket.destroyById(ticket.id));
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ xdescribe('claimBeginning', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('importToNewRefundTicket()', () => {
|
describe('importToNewRefundTicket()', () => {
|
||||||
it('should create a new ticket with negative sales, save an observation, update the state and insert the negative sales into claimEnd', async () => {
|
it('should create a new ticket with negative sales, save an observation, update the state and insert the negative sales into claimEnd', async() => {
|
||||||
let ctxOfSalesAssistant = {req: {accessToken: {userId: 21}}};
|
let ctxOfSalesAssistant = {req: {accessToken: {userId: 21}}};
|
||||||
let claimId = 1;
|
let claimId = 1;
|
||||||
ticket = await app.models.ClaimBeginning.importToNewRefundTicket(ctxOfSalesAssistant, claimId);
|
ticket = await app.models.ClaimBeginning.importToNewRefundTicket(ctxOfSalesAssistant, claimId);
|
||||||
|
|
|
@ -3,13 +3,15 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('Claim importTicketSales()', () => {
|
describe('Claim importTicketSales()', () => {
|
||||||
let claimEnds;
|
let claimEnds;
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async done => {
|
||||||
claimEnds.forEach(async line => {
|
claimEnds.forEach(async line => {
|
||||||
await line.destroy();
|
await line.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should import sales to a claim actions from an specific ticket', async () => {
|
it('should import sales to a claim actions from an specific ticket', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 5}}};
|
let ctx = {req: {accessToken: {userId: 5}}};
|
||||||
claimEnds = await app.models.ClaimEnd.importTicketSales(ctx, {
|
claimEnds = await app.models.ClaimEnd.importTicketSales(ctx, {
|
||||||
claimFk: 1,
|
claimFk: 1,
|
||||||
|
|
|
@ -4,8 +4,10 @@ describe('Claim Create', () => {
|
||||||
let newDate = new Date();
|
let newDate = new Date();
|
||||||
let createdClaimFk;
|
let createdClaimFk;
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async done => {
|
||||||
await app.models.Claim.destroyById(createdClaimFk);
|
await app.models.Claim.destroyById(createdClaimFk);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
let newClaim = {
|
let newClaim = {
|
||||||
|
@ -23,7 +25,7 @@ describe('Claim Create', () => {
|
||||||
|
|
||||||
let params = {claim: newClaim, sales: newSale};
|
let params = {claim: newClaim, sales: newSale};
|
||||||
|
|
||||||
it('should create a new claim', async () => {
|
it('should create a new claim', async() => {
|
||||||
let claim = await app.models.Claim.createFromSales(params);
|
let claim = await app.models.Claim.createFromSales(params);
|
||||||
|
|
||||||
expect(claim.ticketFk).toEqual(newClaim.ticketFk);
|
expect(claim.ticketFk).toEqual(newClaim.ticketFk);
|
||||||
|
@ -39,7 +41,7 @@ describe('Claim Create', () => {
|
||||||
createdClaimFk = claim.id;
|
createdClaimFk = claim.id;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not be able to create a claim if exists that sale', async () => {
|
it('should not be able to create a claim if exists that sale', async() => {
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
await app.models.Claim.createFromSales(params)
|
await app.models.Claim.createFromSales(params)
|
||||||
|
|
|
@ -9,7 +9,7 @@ xdescribe('regularizeClaim()', () => {
|
||||||
let claimEnds = [];
|
let claimEnds = [];
|
||||||
let trashTicket;
|
let trashTicket;
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async done => {
|
||||||
let claim = await app.models.Claim.findById(claimFk);
|
let claim = await app.models.Claim.findById(claimFk);
|
||||||
await claim.updateAttributes({claimStateFk: pendentState});
|
await claim.updateAttributes({claimStateFk: pendentState});
|
||||||
await app.models.Ticket.destroyById(trashTicket.id);
|
await app.models.Ticket.destroyById(trashTicket.id);
|
||||||
|
@ -17,9 +17,11 @@ xdescribe('regularizeClaim()', () => {
|
||||||
claimEnds.forEach(async line => {
|
claimEnds.forEach(async line => {
|
||||||
await line.destroy();
|
await line.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change claim state to resolved', async () => {
|
it('should change claim state to resolved', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 18}}};
|
let ctx = {req: {accessToken: {userId: 18}}};
|
||||||
let params = {claimFk: claimFk};
|
let params = {claimFk: claimFk};
|
||||||
|
|
||||||
|
|
|
@ -14,12 +14,16 @@ describe('Update Claim', () => {
|
||||||
observation: 'observation'
|
observation: 'observation'
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async done => {
|
||||||
newInstance = await app.models.Claim.create(original);
|
newInstance = await app.models.Claim.create(original);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Claim.destroyById(newInstance.id);
|
await app.models.Claim.destroyById(newInstance.id);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw error if isSaleAssistant is false and try to modify a forbidden field', async() => {
|
it('should throw error if isSaleAssistant is false and try to modify a forbidden field', async() => {
|
||||||
|
|
|
@ -4,9 +4,11 @@ describe('Address createDefaultAddress', () => {
|
||||||
let address;
|
let address;
|
||||||
let client;
|
let client;
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await client.updateAttributes({defaultAddressFk: 1});
|
await client.updateAttributes({defaultAddressFk: 1});
|
||||||
await address.destroy();
|
await address.destroy();
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should verify that client defaultAddressFk is untainted', async() => {
|
it('should verify that client defaultAddressFk is untainted', async() => {
|
||||||
|
|
|
@ -8,9 +8,11 @@ describe('Client addressesPropagateRe', () => {
|
||||||
await client.updateAttributes({hasToInvoiceByAddress: true});
|
await client.updateAttributes({hasToInvoiceByAddress: true});
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Address.update({clientFk: 101}, {isEqualizated: false});
|
await app.models.Address.update({clientFk: 101}, {isEqualizated: false});
|
||||||
await client.updateAttributes({hasToInvoiceByAddress: true});
|
await client.updateAttributes({hasToInvoiceByAddress: true});
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => {
|
it('should propagate the isEqualizated on both addresses of Mr Wayne and set hasToInvoiceByAddress to false', async() => {
|
||||||
|
|
|
@ -3,9 +3,11 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('Client confirmTransaction', () => {
|
describe('Client confirmTransaction', () => {
|
||||||
const transactionId = 2;
|
const transactionId = 2;
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Client.rawSql(`
|
await app.models.Client.rawSql(`
|
||||||
CALL hedera.tpvTransactionUndo(?)`, [transactionId]);
|
CALL hedera.tpvTransactionUndo(?)`, [transactionId]);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call confirmTransaction() method to mark transaction as confirmed', async() => {
|
it('should call confirmTransaction() method to mark transaction as confirmed', async() => {
|
||||||
|
|
|
@ -4,13 +4,15 @@ describe('Client Create', () => {
|
||||||
const clientName = 'Wade';
|
const clientName = 'Wade';
|
||||||
const AccountName = 'Deadpool';
|
const AccountName = 'Deadpool';
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
let address = await app.models.Address.findOne({where: {nickname: clientName}});
|
let address = await app.models.Address.findOne({where: {nickname: clientName}});
|
||||||
let client = await app.models.Client.findOne({where: {name: clientName}});
|
let client = await app.models.Client.findOne({where: {name: clientName}});
|
||||||
let account = await app.models.Account.findOne({where: {name: AccountName}});
|
let account = await app.models.Account.findOne({where: {name: AccountName}});
|
||||||
await app.models.Address.destroyById(address.id);
|
await app.models.Address.destroyById(address.id);
|
||||||
await app.models.Client.destroyById(client.id);
|
await app.models.Client.destroyById(client.id);
|
||||||
await app.models.Account.destroyById(account.id);
|
await app.models.Account.destroyById(account.id);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
let newAccount = {
|
let newAccount = {
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('Client updateFiscalData', () => {
|
describe('Client updateFiscalData', () => {
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
let ctxOfAdmin = {req: {accessToken: {userId: 5}}};
|
let ctxOfAdmin = {req: {accessToken: {userId: 5}}};
|
||||||
let validparams = {postcode: 46460};
|
let validparams = {postcode: 46460};
|
||||||
let idWithDataChecked = 101;
|
let idWithDataChecked = 101;
|
||||||
|
|
||||||
await app.models.Client.updateFiscalData(ctxOfAdmin, validparams, idWithDataChecked);
|
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() => {
|
it('should return an error if the user is not administrative and the isTaxDataChecked value is true', async() => {
|
||||||
|
|
|
@ -3,8 +3,10 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('Client createWithInsurance', () => {
|
describe('Client createWithInsurance', () => {
|
||||||
let classificationId;
|
let classificationId;
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.CreditClassification.destroyById(classificationId);
|
await app.models.CreditClassification.destroyById(classificationId);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should verify the classifications and insurances are untainted', async() => {
|
it('should verify the classifications and insurances are untainted', async() => {
|
||||||
|
@ -20,11 +22,11 @@ describe('Client createWithInsurance', () => {
|
||||||
let data = {clientFk: null, started: Date.now(), credit: 999, grade: 255};
|
let data = {clientFk: null, started: Date.now(), credit: 999, grade: 255};
|
||||||
let ctx = {req: {accessToken: {userId: 101}}};
|
let ctx = {req: {accessToken: {userId: 101}}};
|
||||||
await app.models.CreditClassification.createWithInsurance(data, ctx)
|
await app.models.CreditClassification.createWithInsurance(data, ctx)
|
||||||
.catch(e => {
|
.catch(e => {
|
||||||
error = e;
|
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 classifications = await app.models.CreditClassification.find();
|
||||||
let insurances = await app.models.CreditInsurance.find();
|
let insurances = await app.models.CreditInsurance.find();
|
||||||
|
|
|
@ -3,8 +3,10 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('item new()', () => {
|
describe('item new()', () => {
|
||||||
let item;
|
let item;
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Item.destroyById(item.id);
|
await app.models.Item.destroyById(item.id);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new item, adding the name as a tag', async() => {
|
it('should create a new item, adding the name as a tag', async() => {
|
||||||
|
|
|
@ -6,11 +6,13 @@ describe('regularize()', () => {
|
||||||
const trashAddress = 11;
|
const trashAddress = 11;
|
||||||
let trashTicket;
|
let trashTicket;
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async done => {
|
||||||
await app.models.Ticket.destroyById(trashTicket.id);
|
await app.models.Ticket.destroyById(trashTicket.id);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new ticket and add a line', async () => {
|
it('should create a new ticket and add a line', async() => {
|
||||||
let ctx = {req: {accessToken: {userId: 18}}};
|
let ctx = {req: {accessToken: {userId: 18}}};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('item updateTaxes()', () => {
|
describe('item updateTaxes()', () => {
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
let taxesInFixtures = [{id: 3, taxClassFk: 1}];
|
let taxesInFixtures = [{id: 3, taxClassFk: 1}];
|
||||||
|
|
||||||
await app.models.Item.updateTaxes(taxesInFixtures);
|
await app.models.Item.updateTaxes(taxesInFixtures);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the taxClassFk is blank', async() => {
|
it('should throw an error if the taxClassFk is blank', async() => {
|
||||||
|
|
|
@ -2,8 +2,10 @@ const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('order addToOrder()', () => {
|
describe('order addToOrder()', () => {
|
||||||
let rowToDelete;
|
let rowToDelete;
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: 20});
|
await app.models.OrderRow.removes({rows: [rowToDelete], actualOrderId: 20});
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add a row to a given order', async() => {
|
it('should add a row to a given order', async() => {
|
||||||
|
|
|
@ -4,10 +4,12 @@ describe('order removes()', () => {
|
||||||
let row;
|
let row;
|
||||||
let newRow;
|
let newRow;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async done => {
|
||||||
row = await app.models.OrderRow.findOne({where: {id: 12}});
|
row = await app.models.OrderRow.findOne({where: {id: 12}});
|
||||||
row.id = null;
|
row.id = null;
|
||||||
newRow = await app.models.OrderRow.create(row);
|
newRow = await app.models.OrderRow.create(row);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if rows property is empty', async() => {
|
it('should throw an error if rows property is empty', async() => {
|
||||||
|
|
|
@ -4,8 +4,10 @@ let UserError = require('vn-loopback/util/user-error');
|
||||||
describe('order new()', () => {
|
describe('order new()', () => {
|
||||||
let orderId;
|
let orderId;
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Order.destroyById(orderId);
|
await app.models.Order.destroyById(orderId);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the client is frozen', async() => {
|
it('should throw an error if the client is frozen', async() => {
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('Order updateBasicData', () => {
|
describe('Order updateBasicData', () => {
|
||||||
afterAll(async () => {
|
afterAll(async done => {
|
||||||
let validparams = {note: null};
|
let validparams = {note: null};
|
||||||
let orderId = 21;
|
let orderId = 21;
|
||||||
|
|
||||||
await app.models.Order.updateBasicData(validparams, orderId);
|
await app.models.Order.updateBasicData(validparams, orderId);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an error if the order is confirmed', async () => {
|
it('should return an error if the order is confirmed', async() => {
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
let params = [];
|
let params = [];
|
||||||
|
@ -22,7 +24,7 @@ describe('Order updateBasicData', () => {
|
||||||
expect(error.toString()).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
|
expect(error.toString()).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an error if the order has rows', async () => {
|
it('should return an error if the order has rows', async() => {
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
let params = [];
|
let params = [];
|
||||||
|
@ -36,7 +38,7 @@ describe('Order updateBasicData', () => {
|
||||||
expect(error.toString()).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
|
expect(error.toString()).toContain(`You can't make changes on the basic data of an confirmed order or with rows`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return an error if the user is administrative and the isTaxDataChecked value is true BUT the params aint valid', async () => {
|
it('should return an error if the user is administrative and the isTaxDataChecked value is true BUT the params aint valid', async() => {
|
||||||
let error;
|
let error;
|
||||||
|
|
||||||
let invalidparams = {invalid: 'param for update'};
|
let invalidparams = {invalid: 'param for update'};
|
||||||
|
@ -50,7 +52,7 @@ describe('Order updateBasicData', () => {
|
||||||
expect(error.toString()).toContain(`You don't have enough privileges to do that`);
|
expect(error.toString()).toContain(`You don't have enough privileges to do that`);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should update the client fiscal data and return the count if changes made', async () => {
|
it('should update the client fiscal data and return the count if changes made', async() => {
|
||||||
let validparams = {note: 'test note'};
|
let validparams = {note: 'test note'};
|
||||||
let orderId = 21;
|
let orderId = 21;
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,12 @@ describe('sale removes()', () => {
|
||||||
let sale;
|
let sale;
|
||||||
let newsale;
|
let newsale;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async done => {
|
||||||
sale = await app.models.Sale.findOne({where: {id: 9}});
|
sale = await app.models.Sale.findOne({where: {id: 9}});
|
||||||
sale.id = null;
|
sale.id = null;
|
||||||
newsale = await app.models.Sale.create(sale);
|
newsale = await app.models.Sale.create(sale);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the ticket of the given sales is not editable', async() => {
|
it('should throw an error if the ticket of the given sales is not editable', async() => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const app = require('vn-loopback/server/server');
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
describe('sale reserve()', () => {
|
describe('sale reserve()', () => {
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
let params = {
|
let params = {
|
||||||
sales: [
|
sales: [
|
||||||
{id: 7},
|
{id: 7},
|
||||||
|
@ -11,6 +11,8 @@ describe('sale reserve()', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
await app.models.Sale.reserve(params);
|
await app.models.Sale.reserve(params);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the ticket can not be modified', async() => {
|
it('should throw an error if the ticket can not be modified', async() => {
|
||||||
|
|
|
@ -3,14 +3,18 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('ticket changeState()', () => {
|
describe('ticket changeState()', () => {
|
||||||
let ticket;
|
let ticket;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async done => {
|
||||||
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
|
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
|
||||||
originalTicket.id = null;
|
originalTicket.id = null;
|
||||||
ticket = await app.models.Ticket.create(originalTicket);
|
ticket = await app.models.Ticket.create(originalTicket);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Ticket.destroyById(ticket.id);
|
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() => {
|
it('should throw an error if the ticket is not editable and the user isnt production', async() => {
|
||||||
|
|
|
@ -11,12 +11,14 @@ describe('ticket componentUpdate()', () => {
|
||||||
const today = new Date();
|
const today = new Date();
|
||||||
let ticketId = 11;
|
let ticketId = 11;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async done => {
|
||||||
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleSeven);
|
||||||
firstvalueBeforeChange = componentValue.value;
|
firstvalueBeforeChange = componentValue.value;
|
||||||
|
|
||||||
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleEight);
|
[componentValue] = await app.models.SaleComponent.rawSql(componentOfSaleEight);
|
||||||
secondvalueBeforeChange = componentValue.value;
|
secondvalueBeforeChange = componentValue.value;
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should change the agencyMode to modify the sale components value', async() => {
|
it('should change the agencyMode to modify the sale components value', async() => {
|
||||||
|
|
|
@ -3,14 +3,18 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('ticket deleted()', () => {
|
describe('ticket deleted()', () => {
|
||||||
let ticket;
|
let ticket;
|
||||||
|
|
||||||
beforeAll(async() => {
|
beforeAll(async done => {
|
||||||
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
|
let originalTicket = await app.models.Ticket.findOne({where: {id: 16}});
|
||||||
originalTicket.id = null;
|
originalTicket.id = null;
|
||||||
ticket = await app.models.Ticket.create(originalTicket);
|
ticket = await app.models.Ticket.create(originalTicket);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Ticket.destroyById(ticket.id);
|
await app.models.Ticket.destroyById(ticket.id);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should make sure the ticket is not deleted yet', async() => {
|
it('should make sure the ticket is not deleted yet', async() => {
|
||||||
|
|
|
@ -7,8 +7,10 @@ describe('ticket new()', () => {
|
||||||
let today = new Date();
|
let today = new Date();
|
||||||
let ctx = {req: {accessToken: {userId: 1}}};
|
let ctx = {req: {accessToken: {userId: 1}}};
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.Ticket.destroyById(ticket.id);
|
await app.models.Ticket.destroyById(ticket.id);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw an error if the client is frozen', async() => {
|
it('should throw an error if the client is frozen', async() => {
|
||||||
|
|
|
@ -3,8 +3,10 @@ const app = require('vn-loopback/server/server');
|
||||||
describe('ticket model TicketTracking', () => {
|
describe('ticket model TicketTracking', () => {
|
||||||
let ticketTrackingId;
|
let ticketTrackingId;
|
||||||
|
|
||||||
afterAll(async() => {
|
afterAll(async done => {
|
||||||
await app.models.TicketPackaging.destroyById(ticketTrackingId);
|
await app.models.TicketPackaging.destroyById(ticketTrackingId);
|
||||||
|
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should save a ticketTraing as the quantity is greater than 0', async() => {
|
it('should save a ticketTraing as the quantity is greater than 0', async() => {
|
||||||
|
|
Loading…
Reference in New Issue