ctx was poluted by tests
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-12-17 15:14:31 +01:00
parent d83995e64e
commit 7fbbe2fddd
1 changed files with 12 additions and 7 deletions

View File

@ -8,13 +8,14 @@ describe('order filter()', () => {
};
it('should call the filter method with a basic search', async() => {
const myCtx = Object.assign({}, ctx);
const tx = await models.Order.beginTransaction({});
try {
const options = {transaction: tx};
const filter = {where: {'o.id': 2}};
const result = await models.Order.filter(ctx, filter, options);
const result = await models.Order.filter(myCtx, filter, options);
const orderId = result[0].id;
expect(orderId).toEqual(2);
@ -27,13 +28,14 @@ describe('order filter()', () => {
});
it('should call the filter method with a single advanced search', async() => {
const myCtx = Object.assign({}, ctx);
const tx = await models.Order.beginTransaction({});
try {
const options = {transaction: tx};
const filter = {where: {'o.confirmed': false}};
const result = await models.Order.filter(ctx, filter, options);
const result = await models.Order.filter(myCtx, filter, options);
expect(result.length).toEqual(16);
@ -45,13 +47,14 @@ describe('order filter()', () => {
});
it('should call the filter method with a complex advanced search', async() => {
const myCtx = Object.assign({}, ctx);
const tx = await models.Order.beginTransaction({});
try {
const options = {transaction: tx};
const filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 18}};
const result = await models.Order.filter(ctx, filter, options);
const result = await models.Order.filter(myCtx, filter, options);
expect(result.length).toEqual(9);
expect(result[0].id).toEqual(7);
@ -64,14 +67,15 @@ describe('order filter()', () => {
});
it('should return the orders matching the showEmpty on false', async() => {
const myCtx = Object.assign({}, ctx);
const tx = await models.Order.beginTransaction({});
try {
const options = {transaction: tx};
const filter = {};
ctx.args = {showEmpty: false};
const result = await models.Order.filter(ctx, filter, options);
myCtx.args = {showEmpty: false};
const result = await models.Order.filter(myCtx, filter, options);
const hasEmptyLines = result.some(order => {
return order.total === 0;
});
@ -86,14 +90,15 @@ describe('order filter()', () => {
});
it('should return the orders matching the showEmpty on true', async() => {
const myCtx = Object.assign({}, ctx);
const tx = await models.Order.beginTransaction({});
try {
const options = {transaction: tx};
const filter = {};
ctx.args = {showEmpty: true};
const result = await models.Order.filter(ctx, filter, options);
myCtx.args = {showEmpty: true};
const result = await models.Order.filter(myCtx, filter, options);
const hasEmptyLines = result.some(order => {
return order.total === 0;
});