ctx was poluted by tests
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
d83995e64e
commit
7fbbe2fddd
|
@ -8,13 +8,14 @@ describe('order filter()', () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
it('should call the filter method with a basic search', async() => {
|
it('should call the filter method with a basic search', async() => {
|
||||||
|
const myCtx = Object.assign({}, ctx);
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const filter = {where: {'o.id': 2}};
|
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;
|
const orderId = result[0].id;
|
||||||
|
|
||||||
expect(orderId).toEqual(2);
|
expect(orderId).toEqual(2);
|
||||||
|
@ -27,13 +28,14 @@ describe('order filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the filter method with a single advanced search', async() => {
|
it('should call the filter method with a single advanced search', async() => {
|
||||||
|
const myCtx = Object.assign({}, ctx);
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const filter = {where: {'o.confirmed': false}};
|
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);
|
expect(result.length).toEqual(16);
|
||||||
|
|
||||||
|
@ -45,13 +47,14 @@ describe('order filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should call the filter method with a complex advanced search', async() => {
|
it('should call the filter method with a complex advanced search', async() => {
|
||||||
|
const myCtx = Object.assign({}, ctx);
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const filter = {where: {'o.confirmed': false, 'c.salesPersonFk': 18}};
|
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.length).toEqual(9);
|
||||||
expect(result[0].id).toEqual(7);
|
expect(result[0].id).toEqual(7);
|
||||||
|
@ -64,14 +67,15 @@ describe('order filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the orders matching the showEmpty on false', async() => {
|
it('should return the orders matching the showEmpty on false', async() => {
|
||||||
|
const myCtx = Object.assign({}, ctx);
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const filter = {};
|
const filter = {};
|
||||||
ctx.args = {showEmpty: false};
|
myCtx.args = {showEmpty: false};
|
||||||
const result = await models.Order.filter(ctx, filter, options);
|
const result = await models.Order.filter(myCtx, filter, options);
|
||||||
const hasEmptyLines = result.some(order => {
|
const hasEmptyLines = result.some(order => {
|
||||||
return order.total === 0;
|
return order.total === 0;
|
||||||
});
|
});
|
||||||
|
@ -86,14 +90,15 @@ describe('order filter()', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the orders matching the showEmpty on true', async() => {
|
it('should return the orders matching the showEmpty on true', async() => {
|
||||||
|
const myCtx = Object.assign({}, ctx);
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const filter = {};
|
const filter = {};
|
||||||
ctx.args = {showEmpty: true};
|
myCtx.args = {showEmpty: true};
|
||||||
const result = await models.Order.filter(ctx, filter, options);
|
const result = await models.Order.filter(myCtx, filter, options);
|
||||||
const hasEmptyLines = result.some(order => {
|
const hasEmptyLines = result.some(order => {
|
||||||
return order.total === 0;
|
return order.total === 0;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue