#6436 Definir funcion global que añada ctx #2232
|
@ -1,15 +1,8 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
// const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('getStarredModules()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
|
||||
// beforeEach(() => {
|
||||
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
// active: ctx
|
||||
// });
|
||||
// });
|
||||
|
||||
it(`should return the starred modules for a given user`, async() => {
|
||||
const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
|
||||
const starredModules = await models.StarredModule.getStarredModules(ctx);
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
// const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('setPosition()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
|
||||
// beforeEach(() => {
|
||||
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
// active: activeCtx
|
||||
// });
|
||||
// });
|
||||
|
||||
it('should increase the orders module position by replacing it with clients and vice versa', async() => {
|
||||
const tx = await models.StarredModule.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,15 +1,8 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
// const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('toggleStarredModule()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
|
||||
// beforeEach(() => {
|
||||
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
// active: activeCtx
|
||||
// });
|
||||
// });
|
||||
|
||||
it('should create a new starred module and then remove it by calling the method again with same args', async() => {
|
||||
const starredModule = await models.StarredModule.toggleStarredModule(ctx, 'order');
|
||||
let starredModules = await models.StarredModule.getStarredModules(ctx);
|
||||
|
|
|
@ -2,15 +2,7 @@ const app = require('vn-loopback/server/server');
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('claim filter()', () => {
|
||||
let ctx;
|
||||
beforeEach(() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
});
|
||||
const {ctx} = beforeAll;
|
||||
|
||||
it('should return 1 result filtering by id', async() => {
|
||||
const tx = await app.models.Claim.beginTransaction({});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('claim regularizeClaim()', () => {
|
||||
const userId = 18;
|
||||
|
@ -41,17 +41,7 @@ describe('claim regularizeClaim()', () => {
|
|||
}
|
||||
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
mockLoopBackContext();
|
||||
});
|
||||
|
||||
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {
|
||||
|
|
|
@ -1,22 +1,11 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
const i18n = require('i18n');
|
||||
describe('Update Claim', () => {
|
||||
let url;
|
||||
let claimStatesMap = {};
|
||||
beforeAll(async() => {
|
||||
url = await app.models.Url.getUrl();
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
mockLoopBackContext();
|
||||
const claimStates = await app.models.ClaimState.find();
|
||||
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
|
||||
});
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Update Claim', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
mockLoopBackContext();
|
||||
});
|
||||
const newDate = Date.vnNew();
|
||||
const original = {
|
||||
|
|
|
@ -1,21 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
// const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('AgencyTerm createInvoiceIn()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const {ctx} = beforeAll;
|
||||
const rows = [
|
||||
{
|
||||
routeFk: 2,
|
||||
|
|
|
@ -1,20 +1,9 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('route clone()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
mockLoopBackContext();
|
||||
});
|
||||
|
||||
const createdDate = Date.vnNew();
|
||||
|
|
|
@ -1,20 +1,17 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const LoopBackContext = require('loopback-context');
|
||||
// const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('route guessPriority()', () => {
|
||||
const targetRouteId = 7;
|
||||
let routeTicketsToRestore;
|
||||
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
__: () => {}
|
||||
};
|
||||
const {ctx} = beforeAll;
|
||||
|
||||
beforeAll(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
// beforeAll(() => {
|
||||
// spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
// active: activeCtx
|
||||
// });
|
||||
// });
|
||||
|
||||
afterAll(async() => {
|
||||
let restoreFixtures = [];
|
||||
|
@ -25,9 +22,9 @@ describe('route guessPriority()', () => {
|
|||
});
|
||||
|
||||
it('should call guessPriority() then check all tickets in that route have their priorities defined', async() => {
|
||||
const ctx = {
|
||||
req: activeCtx
|
||||
};
|
||||
// const ctx = {
|
||||
// req: activeCtx
|
||||
// };
|
||||
routeTicketsToRestore = await app.models.Ticket.find({where: {routeFk: targetRouteId}});
|
||||
|
||||
await app.models.Route.guessPriority(ctx, targetRouteId);
|
||||
|
|
|
@ -1,19 +1,9 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('route updateWorkCenter()', () => {
|
||||
beforeAll(async() => {
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
http: {
|
||||
req: {
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
mockLoopBackContext();
|
||||
});
|
||||
const routeId = 1;
|
||||
|
||||
|
|
Loading…
Reference in New Issue