test
This commit is contained in:
parent
0c7ddd863d
commit
3db3d65600
|
@ -8,35 +8,44 @@ fdescribe('Receipt createReceipt', () => {
|
||||||
const description = 'Receipt description';
|
const description = 'Receipt description';
|
||||||
|
|
||||||
it('should create a new receipt', async() => {
|
it('should create a new receipt', async() => {
|
||||||
const ctx = {
|
const bankFk = 1;
|
||||||
|
let ctx = {
|
||||||
args: {
|
args: {
|
||||||
clientFk: clientFk,
|
clientFk: clientFk,
|
||||||
payed: payed,
|
payed: payed,
|
||||||
companyFk: companyFk,
|
companyFk: companyFk,
|
||||||
bankFk: 1,
|
bankFk: bankFk,
|
||||||
amountPaid: amountPaid,
|
amountPaid: amountPaid,
|
||||||
description: description
|
description: description
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const receipt = await app.models.Receipt.createReceipt(ctx);
|
const receipt = await app.models.Receipt.createReceipt(ctx);
|
||||||
console.log(receipt);
|
delete ctx.args.payed;
|
||||||
console.log(ctx.args);
|
|
||||||
|
|
||||||
expect(receipt).toEqual(jasmine.objectContaining(ctx.args));
|
expect(receipt).toEqual(jasmine.objectContaining(ctx.args));
|
||||||
|
|
||||||
|
const till = await models.Till.findOne({
|
||||||
|
where: {
|
||||||
|
bankFk: bankFk,
|
||||||
|
in: amountPaid,
|
||||||
|
dated: payed,
|
||||||
|
number: clientFk
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// restores
|
// restores
|
||||||
await receipt.destroy();
|
await receipt.destroy();
|
||||||
// destroy till
|
await till.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw Invalid account if compensationAccount does not belongs to a client nor a supplier', async() => {
|
it('should throw Invalid account if compensationAccount does not belongs to a client nor a supplier', async() => {
|
||||||
|
const bankFk = 3;
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
clientFk: clientFk,
|
clientFk: clientFk,
|
||||||
payed: payed,
|
payed: payed,
|
||||||
companyFk: companyFk,
|
companyFk: companyFk,
|
||||||
bankFk: 3,
|
bankFk: bankFk,
|
||||||
amountPaid: amountPaid,
|
amountPaid: amountPaid,
|
||||||
description: description,
|
description: description,
|
||||||
compensationAccount: 'non existing account'
|
compensationAccount: 'non existing account'
|
||||||
|
@ -51,16 +60,16 @@ fdescribe('Receipt createReceipt', () => {
|
||||||
|
|
||||||
expect(err).toBeDefined();
|
expect(err).toBeDefined();
|
||||||
expect(err.message).toEqual('Invalid account');
|
expect(err.message).toEqual('Invalid account');
|
||||||
// validar que no ha creado el receipt porque el rollback ha funcionado
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new receipt with a compensation for a client', async() => {
|
it('should create a new receipt with a compensation for a client', async() => {
|
||||||
|
const bankFk = 3;
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
clientFk: clientFk,
|
clientFk: clientFk,
|
||||||
payed: payed,
|
payed: payed,
|
||||||
companyFk: companyFk,
|
companyFk: companyFk,
|
||||||
bankFk: 3,
|
bankFk: bankFk,
|
||||||
amountPaid: amountPaid,
|
amountPaid: amountPaid,
|
||||||
description: description,
|
description: description,
|
||||||
compensationAccount: '4300000001'
|
compensationAccount: '4300000001'
|
||||||
|
@ -76,20 +85,28 @@ fdescribe('Receipt createReceipt', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const till = await models.Till.findOne({
|
||||||
|
where: {
|
||||||
|
bankFk: bankFk,
|
||||||
|
in: amountPaid,
|
||||||
|
dated: payed,
|
||||||
|
number: clientFk
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
expect(receipt).toEqual(jasmine.objectContaining(ctx.args));
|
expect(receipt).toEqual(jasmine.objectContaining(ctx.args));
|
||||||
expect(receiptCompensated.amountPaid).toEqual(-receiptCompensated.amountPaid);
|
expect(receipt.amountPaid).toEqual(-receiptCompensated.amountPaid);
|
||||||
// jasmine.objectContaining vs expect.objectContaining
|
|
||||||
|
|
||||||
// restores
|
// restores
|
||||||
await receipt.destroy();
|
await receipt.destroy();
|
||||||
await receiptCompensated.destroy();
|
await receiptCompensated.destroy();
|
||||||
// destroy till
|
await till.destroy();
|
||||||
// destroy XDiario
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should create a new receipt with a compensation for a supplier', async() => {
|
it('should create a new receipt with a compensation for a supplier', async() => {
|
||||||
const ctx = {
|
const ctx = {
|
||||||
args: {
|
args: {
|
||||||
|
clientFk: clientFk,
|
||||||
payed: payed,
|
payed: payed,
|
||||||
companyFk: companyFk,
|
companyFk: companyFk,
|
||||||
bankFk: 3,
|
bankFk: 3,
|
||||||
|
@ -111,7 +128,6 @@ fdescribe('Receipt createReceipt', () => {
|
||||||
|
|
||||||
expect(receipt).toEqual(jasmine.objectContaining(ctx.args));
|
expect(receipt).toEqual(jasmine.objectContaining(ctx.args));
|
||||||
// expect(receiptCompensated.amountPaid).toEqual(receiptCompensated.amountPaid);
|
// expect(receiptCompensated.amountPaid).toEqual(receiptCompensated.amountPaid);
|
||||||
// jasmine.objectContaining vs expect.objectContaining
|
|
||||||
|
|
||||||
// restores
|
// restores
|
||||||
await receipt.destroy();
|
await receipt.destroy();
|
||||||
|
|
Loading…
Reference in New Issue