refactor: refs #6436 fourth wave
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jon Elias 2024-06-11 12:02:15 +02:00
parent 093eaeb475
commit bd45352215
13 changed files with 25 additions and 156 deletions

View File

@ -1,10 +1,7 @@
const models = require('vn-loopback/server/server').models;
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('item new()', () => {
beforeAll(async() => {
mockLoopBackContext();
});
const {ctx} = beforeAll;
it('should create a new item, adding the name as a tag', async() => {
const tx = await models.Item.beginTransaction({});

View File

@ -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('tag onSubmit()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
it('should delete a tag', async() => {

View File

@ -1,18 +1,9 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('ticket deleteExpeditions()', () => {
let ctx;
beforeAll(async() => {
ctx = {
accessToken: {userId: 9},
req: {
headers: {origin: 'http://localhost'}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: ctx
});
mockLoopBackContext();
});
it('should delete the selected expeditions', async() => {

View File

@ -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('ticket moveExpeditions()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
it('should move the selected expeditions to new ticket', async() => {

View File

@ -1,20 +1,10 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('sale canEdit()', () => {
const employeeId = 1;
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
describe('sale not exists', () => {

View File

@ -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('sale deleteSales()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
it('should throw an error if the ticket of the given sales is not editable', async() => {

View File

@ -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('sale reserve()', () => {
const ctx = {
@ -11,17 +11,7 @@ describe('sale reserve()', () => {
};
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
it('should throw an error if the ticket can not be modified', async() => {

View File

@ -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('sale updateConcept()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
const ctx = {req: {accessToken: {userId: 9}}};

View File

@ -1,29 +1,10 @@
const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context');
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('ticket-request confirm()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
let ctx = {
req: {
accessToken: {userId: 9},
headers: {origin: 'http://localhost'}
}
};
ctx.req.__ = value => {
return value;
};
it(`should throw an error if the item doesn't exist`, async() => {
const tx = await models.TicketRequest.beginTransaction({});

View File

@ -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('ticket componentUpdate()', () => {
const userID = 1101;
@ -17,17 +17,7 @@ describe('ticket componentUpdate()', () => {
let componentValue;
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}});
deliveryComponentId = deliveryComponenet.id;
componentOfSaleSeven = `SELECT value

View File

@ -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('ticket merge()', () => {
const tickets = {
@ -11,17 +11,7 @@ describe('ticket merge()', () => {
};
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
const ctx = {

View File

@ -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('sale updateDiscount()', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
const originalSaleId = 8;

View File

@ -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('ticket model TicketTracking', () => {
beforeAll(async() => {
const activeCtx = {
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
mockLoopBackContext();
});
let ticketTrackingId;