7729-devToTest_2430 #2739

Merged
alexm merged 339 commits from 7729-devToTest_2430 into test 2024-07-16 07:11:37 +00:00
13 changed files with 25 additions and 156 deletions
Showing only changes of commit bd45352215 - Show all commits

View File

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

View File

@ -1,19 +1,9 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('tag onSubmit()', () => { describe('tag onSubmit()', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
it('should delete a tag', async() => { it('should delete a tag', async() => {

View File

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

View File

@ -1,19 +1,9 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('ticket moveExpeditions()', () => { describe('ticket moveExpeditions()', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
it('should move the selected expeditions to new ticket', async() => { 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 models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('sale canEdit()', () => { describe('sale canEdit()', () => {
const employeeId = 1; const employeeId = 1;
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
describe('sale not exists', () => { describe('sale not exists', () => {

View File

@ -1,19 +1,9 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('sale deleteSales()', () => { describe('sale deleteSales()', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
it('should throw an error if the ticket of the given sales is not editable', async() => { 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 models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('sale reserve()', () => { describe('sale reserve()', () => {
const ctx = { const ctx = {
@ -11,17 +11,7 @@ describe('sale reserve()', () => {
}; };
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
it('should throw an error if the ticket can not be modified', async() => { 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 models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('sale updateConcept()', () => { describe('sale updateConcept()', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
const ctx = {req: {accessToken: {userId: 9}}}; const ctx = {req: {accessToken: {userId: 9}}};

View File

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

View File

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

View File

@ -1,5 +1,5 @@
const models = require('vn-loopback/server/server').models; const models = require('vn-loopback/server/server').models;
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('ticket merge()', () => { describe('ticket merge()', () => {
const tickets = { const tickets = {
@ -11,17 +11,7 @@ describe('ticket merge()', () => {
}; };
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
const ctx = { const ctx = {

View File

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

View File

@ -1,19 +1,9 @@
const app = require('vn-loopback/server/server'); const app = require('vn-loopback/server/server');
const LoopBackContext = require('loopback-context'); const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
describe('ticket model TicketTracking', () => { describe('ticket model TicketTracking', () => {
beforeAll(async() => { beforeAll(async() => {
const activeCtx = { mockLoopBackContext();
accessToken: {userId: 9},
http: {
req: {
headers: {origin: 'http://localhost'}
}
}
};
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
active: activeCtx
});
}); });
let ticketTrackingId; let ticketTrackingId;