This commit is contained in:
parent
ea771cb910
commit
4784e71350
|
@ -2,18 +2,24 @@ const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const LoopBackContext = require('loopback-context');
|
||||||
|
|
||||||
describe('invoiceOut delete()', () => {
|
describe('invoiceOut delete()', () => {
|
||||||
const invoiceId = 2;
|
const invoiceOutId = 2;
|
||||||
const userId = 106;
|
const userId = 106;
|
||||||
const activeCtx = {
|
const activeCtx = {
|
||||||
accessToken: {userId: userId},
|
accessToken: {userId: userId},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||||
|
active: activeCtx
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should check that there is one ticket in the target invoiceOut', async() => {
|
it('should check that there is one ticket in the target invoiceOut', async() => {
|
||||||
const tx = await models.InvoiceOut.beginTransaction({});
|
const tx = await models.InvoiceOut.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const invoiceOut = await models.InvoiceOut.findById(invoiceId, {}, options);
|
const invoiceOut = await models.InvoiceOut.findById(invoiceOutId , {}, options);
|
||||||
const tickets = await models.Ticket.find({where: {refFk: invoiceOut.ref}}, options);
|
const tickets = await models.Ticket.find({where: {refFk: invoiceOut.ref}}, options);
|
||||||
|
|
||||||
expect(tickets.length).toEqual(1);
|
expect(tickets.length).toEqual(1);
|
||||||
|
@ -31,14 +37,10 @@ describe('invoiceOut delete()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
await models.InvoiceOut.delete(invoiceOutId, options);
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
|
|
||||||
await models.InvoiceOut.delete(invoiceId, options);
|
|
||||||
const originalTicket = await models.Ticket.findById(3, {}, options);
|
const originalTicket = await models.Ticket.findById(3, {}, options);
|
||||||
|
|
||||||
const deletedInvoiceOut = await models.InvoiceOut.findById(invoiceId, {}, options);
|
const deletedInvoiceOut = await models.InvoiceOut.findById(invoiceOutId, {}, options);
|
||||||
|
|
||||||
expect(deletedInvoiceOut).toBeNull();
|
expect(deletedInvoiceOut).toBeNull();
|
||||||
expect(originalTicket.refFk).toBeNull();
|
expect(originalTicket.refFk).toBeNull();
|
||||||
|
@ -55,10 +57,6 @@ describe('invoiceOut delete()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
ASIEN: 2
|
ASIEN: 2
|
||||||
|
@ -110,10 +108,6 @@ describe('invoiceOut delete()', () => {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
|
|
||||||
const filter = {
|
const filter = {
|
||||||
where: {
|
where: {
|
||||||
ASIEN: 1
|
ASIEN: 1
|
||||||
|
|
|
@ -2,4 +2,4 @@ Subject: Linked Accounting Entry Deleted
|
||||||
Title: Linked Accounting Entry Deleted
|
Title: Linked Accounting Entry Deleted
|
||||||
Description: The linked accounting entry that was associated with SAGE has been deleted. <br/><br/>
|
Description: The linked accounting entry that was associated with SAGE has been deleted. <br/><br/>
|
||||||
Entry No. {0} <br/><br/>
|
Entry No. {0} <br/><br/>
|
||||||
This entry has been deleted because the associated invoice {0} has been removed.
|
This entry has been deleted because the associated invoice {1} has been removed.
|
||||||
|
|
|
@ -2,4 +2,4 @@ subject: Asiento contable enlazado eliminado
|
||||||
title: Asiento contable enlazado eliminado
|
title: Asiento contable enlazado eliminado
|
||||||
description: Se ha borrado el asiento contable que se encuentraba enlazado a SAGE <br/><br/>
|
description: Se ha borrado el asiento contable que se encuentraba enlazado a SAGE <br/><br/>
|
||||||
Asientos nº {0} <br/><br/>
|
Asientos nº {0} <br/><br/>
|
||||||
Este asiento se ha borrado porque se ha eliminado la factura asociada {0}
|
Este asiento se ha borrado porque se ha eliminado la factura asociada {1}
|
||||||
|
|
Loading…
Reference in New Issue