refactor: refs #6436 end first wave of changes in modules
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
665d03f048
commit
944355d54f
|
@ -1,19 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('ticket moveExpeditions()', () => {
|
||||
beforeAll(async() => {
|
||||
mockLoopBackContext();
|
||||
});
|
||||
const {ctx} = beforeAll;
|
||||
|
||||
it('should move the selected expeditions to new ticket', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 9}},
|
||||
args: {},
|
||||
params: {}
|
||||
};
|
||||
const myCtx = Object.assign({}, ctx);
|
||||
const myCtx = ctx;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
@ -28,7 +20,7 @@ describe('ticket moveExpeditions()', () => {
|
|||
|
||||
};
|
||||
|
||||
const ticket = await models.Expedition.moveExpeditions(myCtx, options);
|
||||
const ticket = await models.Expedition.moveExpeditions(ctx, options);
|
||||
|
||||
const newestTicketIdInFixtures = 27;
|
||||
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket isEditableOrThrow()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
it('should throw an error as the ticket does not exist', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
let error;
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 9}}
|
||||
};
|
||||
|
||||
await models.Ticket.isEditableOrThrow(ctx, 9999, options);
|
||||
await tx.rollback();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('ticket merge()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const tickets = {
|
||||
originId: 13,
|
||||
destinationId: 12,
|
||||
|
@ -10,16 +10,6 @@ describe('ticket merge()', () => {
|
|||
workerFk: 1
|
||||
};
|
||||
|
||||
beforeAll(async() => {
|
||||
mockLoopBackContext();
|
||||
});
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost:5000'},
|
||||
}
|
||||
};
|
||||
ctx.req.__ = value => {
|
||||
return value;
|
||||
};
|
||||
|
|
|
@ -3,6 +3,7 @@ const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
|||
|
||||
describe('ticket recalculateComponents()', () => {
|
||||
const ticketId = 11;
|
||||
const {ctx} = beforeAll;
|
||||
|
||||
it('should update the ticket components', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
@ -10,7 +11,6 @@ describe('ticket recalculateComponents()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const response = await models.Ticket.recalculateComponents(ctx, ticketId, options);
|
||||
|
||||
expect(response.affectedRows).toBeDefined();
|
||||
|
@ -29,7 +29,6 @@ describe('ticket recalculateComponents()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const immutableTicketId = 1;
|
||||
await models.Ticket.recalculateComponents(ctx, immutableTicketId, options);
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket sendSms()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
it('should send a message and log it', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const id = 11;
|
||||
const destination = 222222222;
|
||||
const message = 'this is the message created in a test';
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Worker absences()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
it('should get the absence calendar for a full year contract', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 1106}}};
|
||||
const workerId = 1106;
|
||||
|
@ -20,7 +21,6 @@ describe('Worker absences()', () => {
|
|||
|
||||
it('should get the absence calendar for a permanent contract', async() => {
|
||||
const businessId = 1106;
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
|
||||
const now = Date.vnNew();
|
||||
const year = now.getFullYear();
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('department getLeaves()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const {ctx} = beforeAll;
|
||||
it('should return the department and the childs containing the search value', async() => {
|
||||
let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA');
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('worker mySubordinates()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
it('should return an array of subordinates greather than 1', async() => {
|
||||
let ctx = {req: {accessToken: {userId: 9}}};
|
||||
let result = await app.models.Worker.mySubordinates(ctx);
|
||||
|
||||
expect(result.length).toBeGreaterThan(1);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Agency getAgenciesWithWarehouse()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const today = Date.vnNew();
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
it('should return the agencies that can handle the given delivery request', async() => {
|
||||
const tx = await app.models.Zone.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('Agency landsThatDay()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const {ctx} = beforeAll;
|
||||
const today = Date.vnNew();
|
||||
it('should return a list of agencies that can land a shipment on a day for an address', async() => {
|
||||
const tx = await models.Agency.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('zone getEvents()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const {ctx} = beforeAll;
|
||||
it('should return all events for the specified geo and agency mode', async() => {
|
||||
const tx = await models.Zone.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('zone getLeaves()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const {ctx} = beforeAll;
|
||||
it('should return the country and the childs containing the search value', async() => {
|
||||
const tx = await models.Zone.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('zone getUpcomingDeliveries()', () => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}};
|
||||
const {ctx} = beforeAll;
|
||||
it('should check returns data', async() => {
|
||||
const tx = await models.Zone.beginTransaction({});
|
||||
|
||||
|
|
Loading…
Reference in New Issue