refs #6436 feat: use mocks
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
d6ee5d571e
commit
8ab9063b50
|
@ -1,15 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('collection getTickets()', () => {
|
describe('collection getTickets()', () => {
|
||||||
let ctx;
|
const {ctx} = beforeAll;
|
||||||
beforeAll(async() => {
|
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should get tickets, sales and barcodes from collection', async() => {
|
it('should get tickets, sales and barcodes from collection', async() => {
|
||||||
const tx = await models.Collection.beginTransaction({});
|
const tx = await models.Collection.beginTransaction({});
|
||||||
|
|
|
@ -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('Client Create', () => {
|
describe('Client Create', () => {
|
||||||
const newAccount = {
|
const newAccount = {
|
||||||
|
@ -17,18 +17,7 @@ describe('Client Create', () => {
|
||||||
delete newAccountWithoutEmail.email;
|
delete newAccountWithoutEmail.email;
|
||||||
|
|
||||||
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 not find Deadpool as he's not created yet`, async() => {
|
it(`should not find Deadpool as he's not created yet`, async() => {
|
||||||
|
|
|
@ -1,24 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('invoiceIn corrective()', () => {
|
describe('invoiceIn corrective()', () => {
|
||||||
let ctx;
|
const {ctx} = beforeAll;
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Sale.beginTransaction({});
|
tx = await models.Sale.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -1,26 +1,14 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
// #6276
|
// #6276
|
||||||
describe('ItemShelving upsertItem()', () => {
|
describe('ItemShelving upsertItem()', () => {
|
||||||
const warehouseFk = 1;
|
const warehouseFk = 1;
|
||||||
let ctx;
|
|
||||||
|
const {ctx} = beforeAll;
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.ItemShelving.beginTransaction({});
|
tx = await models.ItemShelving.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -1,24 +1,15 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
const {mockLoopBackContext, mockBeforeAll} = require('vn-loopback/../../back/vn-jasmine');
|
||||||
|
|
||||||
describe('Ticket cloning - clone function', () => {
|
describe('Ticket cloning - clone function', () => {
|
||||||
let ctx;
|
let ctx = mockBeforeAll({ejemploe: true});
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
|
beforeAll(async() => {
|
||||||
|
mockLoopBackContext();
|
||||||
|
});
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Sale.beginTransaction({});
|
tx = await models.Sale.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -1,22 +1,11 @@
|
||||||
const {models} = require('vn-loopback/server/server');
|
const {models} = require('vn-loopback/server/server');
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Ticket addSaleByCode()', () => {
|
describe('Ticket addSaleByCode()', () => {
|
||||||
const quantity = 3;
|
const quantity = 3;
|
||||||
const ticketFk = 13;
|
const ticketFk = 13;
|
||||||
const warehouseFk = 1;
|
const warehouseFk = 1;
|
||||||
beforeAll(async() => {
|
|
||||||
activeCtx = {
|
const {ctx} = beforeAll;
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'},
|
|
||||||
__: value => value
|
|
||||||
}
|
|
||||||
};
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should add a new sale', async() => {
|
it('should add a new sale', async() => {
|
||||||
const tx = await models.Ticket.beginTransaction({});
|
const tx = await models.Ticket.beginTransaction({});
|
||||||
|
@ -26,7 +15,7 @@ describe('Ticket addSaleByCode()', () => {
|
||||||
const code = '1111111111';
|
const code = '1111111111';
|
||||||
|
|
||||||
const salesBefore = await models.Sale.find(null, options);
|
const salesBefore = await models.Sale.find(null, options);
|
||||||
await models.Ticket.addSaleByCode(activeCtx, code, quantity, ticketFk, warehouseFk, options);
|
await models.Ticket.addSaleByCode(ctx, code, quantity, ticketFk, warehouseFk, options);
|
||||||
const salesAfter = await models.Sale.find(null, options);
|
const salesAfter = await models.Sale.find(null, options);
|
||||||
|
|
||||||
expect(salesAfter.length).toEqual(salesBefore.length + 1);
|
expect(salesAfter.length).toEqual(salesBefore.length + 1);
|
||||||
|
|
|
@ -1,26 +1,13 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
const LoopBackContext = require('loopback-context');
|
|
||||||
|
|
||||||
describe('Ticket cloning - clone function', () => {
|
describe('Ticket cloning - clone function', () => {
|
||||||
let ctx;
|
const {ctx} = beforeAll;
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
const ticketId = 1;
|
const ticketId = 1;
|
||||||
const shipped = Date.vnNew();
|
const shipped = Date.vnNew();
|
||||||
|
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
|
||||||
active: ctx.req
|
|
||||||
});
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Ticket.beginTransaction({});
|
tx = await models.Ticket.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
|
@ -4,18 +4,11 @@ describe('Ticket transferClient()', () => {
|
||||||
const originalTicketId = 8;
|
const originalTicketId = 8;
|
||||||
const refundTicketId = 24;
|
const refundTicketId = 24;
|
||||||
const clientId = 1;
|
const clientId = 1;
|
||||||
let ctx;
|
|
||||||
|
const {ctx} = beforeAll;
|
||||||
let options;
|
let options;
|
||||||
let tx;
|
let tx;
|
||||||
beforeEach(async() => {
|
beforeEach(async() => {
|
||||||
ctx = {
|
|
||||||
req: {
|
|
||||||
accessToken: {userId: 9},
|
|
||||||
headers: {origin: 'http://localhost'}
|
|
||||||
},
|
|
||||||
args: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
options = {transaction: tx};
|
options = {transaction: tx};
|
||||||
tx = await models.Ticket.beginTransaction({});
|
tx = await models.Ticket.beginTransaction({});
|
||||||
options.transaction = tx;
|
options.transaction = tx;
|
||||||
|
|
Loading…
Reference in New Issue