fix: refs #7277 error test
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
2e3fb7646f
commit
e2f1fea6be
|
@ -15,9 +15,7 @@ describe('ticket assignCollection()', () => {
|
|||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: ctx.req});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
|
@ -25,7 +23,7 @@ describe('ticket assignCollection()', () => {
|
|||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
if (tx) await tx.rollback();
|
||||
});
|
||||
|
||||
it('should throw an error when there is not picking tickets', async() => {
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('InvoiceOut refundAndInvoice()', () => {
|
|||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx});
|
||||
});
|
||||
|
||||
fit('should refund an invoice and create a new invoice', async() => {
|
||||
it('should refund an invoice and create a new invoice', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
|
|
|
@ -2,16 +2,11 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
describe('InvoiceOut transfer()', () => {
|
||||
fdescribe('InvoiceOut transfer()', () => {
|
||||
const userId = 5;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId},
|
||||
__: (key, obj) => `Translated: ${key}, ${JSON.stringify(obj)}`,
|
||||
getLocale: () => 'es'
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
let options;
|
||||
let tx;
|
||||
let ctx;
|
||||
const activeCtx = {accessToken: {userId}};
|
||||
const id = 4;
|
||||
const newClientFk = 1101;
|
||||
|
@ -19,13 +14,28 @@ describe('InvoiceOut transfer()', () => {
|
|||
const siiTypeInvoiceOutFk = 1;
|
||||
const invoiceCorrectionTypeFk = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 1106},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => value,
|
||||
getLocale: () => 'es'
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({active: activeCtx});
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
});
|
||||
|
||||
afterEach(async() => {
|
||||
await tx.rollback();
|
||||
});
|
||||
|
||||
it('should transfer an invoice to a new client and return the new invoice ID', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const makeInvoice = true;
|
||||
|
||||
try {
|
||||
|
@ -45,7 +55,7 @@ describe('InvoiceOut transfer()', () => {
|
|||
|
||||
const transferredTickets = await models.Ticket.find({
|
||||
where: {
|
||||
invoiceOutFk: result,
|
||||
refFk: result,
|
||||
clientFk: newClientFk
|
||||
}
|
||||
}, options);
|
||||
|
@ -60,8 +70,6 @@ describe('InvoiceOut transfer()', () => {
|
|||
});
|
||||
|
||||
it('should throw an error if original invoice is not found', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const makeInvoice = true;
|
||||
try {
|
||||
await models.InvoiceOut.transfer(
|
||||
|
@ -83,8 +91,6 @@ describe('InvoiceOut transfer()', () => {
|
|||
});
|
||||
|
||||
it('should throw an error if the new client is the same as the original client', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
const makeInvoice = true;
|
||||
const originalInvoice = await models.InvoiceOut.findById(id);
|
||||
|
||||
|
@ -107,40 +113,31 @@ describe('InvoiceOut transfer()', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('should not create a new invoice if makeInvoice is false', async() => {
|
||||
const tx = await models.InvoiceOut.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
fit('should not create a new invoice if makeInvoice is false', async() => {
|
||||
const originalTickets = await models.Ticket.find({
|
||||
where: {clientFk: newClientFk, refFk: null},
|
||||
options
|
||||
});
|
||||
|
||||
try {
|
||||
const originalTickets = await models.Ticket.find({
|
||||
where: {clientFk: newClientFk, invoiceOutFk: null},
|
||||
options
|
||||
});
|
||||
const result = await models.InvoiceOut.transfer(
|
||||
ctx,
|
||||
id,
|
||||
newClientFk,
|
||||
cplusRectificationTypeFk,
|
||||
siiTypeInvoiceOutFk,
|
||||
invoiceCorrectionTypeFk,
|
||||
false,
|
||||
options
|
||||
);
|
||||
|
||||
const result = await models.InvoiceOut.transfer(
|
||||
ctx,
|
||||
id,
|
||||
newClientFk,
|
||||
cplusRectificationTypeFk,
|
||||
siiTypeInvoiceOutFk,
|
||||
invoiceCorrectionTypeFk,
|
||||
false,
|
||||
options
|
||||
);
|
||||
expect(result).toBeUndefined();
|
||||
|
||||
expect(result).toBeUndefined();
|
||||
// await tx.commit();
|
||||
const transferredTickets = await models.Ticket.find({
|
||||
where: {clientFk: newClientFk, refFk: null},
|
||||
options
|
||||
});
|
||||
|
||||
const transferredTickets = await models.Ticket.find({
|
||||
where: {clientFk: newClientFk, invoiceOutFk: null},
|
||||
options
|
||||
});
|
||||
|
||||
expect(transferredTickets.length).toBeGreaterThan(originalTickets.length);
|
||||
|
||||
await tx.rollback();
|
||||
} catch (e) {
|
||||
await tx.rollback();
|
||||
throw e;
|
||||
}
|
||||
expect(transferredTickets.length).toBeGreaterThan(originalTickets.length);
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue