This commit is contained in:
parent
324d7ef7ae
commit
61a588b57c
|
@ -4,7 +4,7 @@ describe('collection getSales()', () => {
|
|||
const collectionOrTicketFk = 999999;
|
||||
const print = true;
|
||||
const source = 'CHECKER';
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should return a collection with tickets, placements and barcodes settled correctly', async() => {
|
||||
const tx = await models.Collection.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('collection getTickets()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should get tickets, sales and barcodes from collection', async() => {
|
||||
const tx = await models.Collection.beginTransaction({});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('setSaleQuantity()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should change quantity sale', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('getStarredModules()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it(`should return the starred modules for a given user`, async() => {
|
||||
const newStarred = await models.StarredModule.create({workerFk: 9, moduleFk: 'customer', position: 1});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('setPosition()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should increase the orders module position by replacing it with clients and vice versa', async() => {
|
||||
const tx = await models.StarredModule.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
|
||||
describe('toggleStarredModule()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
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');
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('userConfig getUserConfig()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it(`should return the configuration data of a given user`, async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('loopback model MailAliasAccount', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should add a mail Alias', async() => {
|
||||
const tx = await models.MailAliasAccount.beginTransaction({});
|
||||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const options = {transaction: tx, ctx};
|
||||
await models.MailAliasAccount.create({mailAlias: 2, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
|
@ -23,7 +24,7 @@ describe('loopback model MailAliasAccount', () => {
|
|||
let error;
|
||||
|
||||
try {
|
||||
const options = {transaction: tx, accessToken: {userId: 9}};
|
||||
const options = {transaction: tx, ctx};
|
||||
await models.MailAliasAccount.create({mailAlias: 3, account: 5}, options);
|
||||
|
||||
await tx.rollback();
|
||||
|
|
|
@ -1,42 +1,48 @@
|
|||
|
||||
const LoopBackContext = require('loopback-context');
|
||||
const DEFAULT_ACCESS_TOKEN = {accessToken: {userId: 9}};
|
||||
const getAccessToken = (userId = 9) => {
|
||||
return {accessToken: {userId}};
|
||||
};
|
||||
const DEFAULT_HEADERS = {headers: {origin: 'http://localhost'}};
|
||||
const DEFAULT_BEFORE_ALL = {
|
||||
ctx: {
|
||||
const default_before_all = userId => {
|
||||
return {
|
||||
req: {
|
||||
...DEFAULT_ACCESS_TOKEN,
|
||||
...DEFAULT_HEADERS
|
||||
...getAccessToken(userId),
|
||||
...DEFAULT_HEADERS,
|
||||
...{__: value => value}
|
||||
|
||||
},
|
||||
args: {}
|
||||
}
|
||||
};
|
||||
const DEFAULT_LOOPBACK_CTX = {
|
||||
...DEFAULT_ACCESS_TOKEN,
|
||||
};
|
||||
const default_loopback_ctx = userId => {
|
||||
return {
|
||||
...getAccessToken(userId),
|
||||
...default_before_all(userId),
|
||||
http: {
|
||||
req: {
|
||||
...DEFAULT_HEADERS
|
||||
}
|
||||
...default_before_all(userId)
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
};
|
||||
|
||||
function vnBeforeAll(value = DEFAULT_BEFORE_ALL) {
|
||||
Object.assign(beforeAll, value);
|
||||
function vnBeforeAll() {
|
||||
Object.assign(beforeAll, {getCtx: default_before_all});
|
||||
Object.assign(beforeAll, {mockLoopBackContext});
|
||||
}
|
||||
function mockBeforeAll(value = DEFAULT_BEFORE_ALL) {
|
||||
function mockBeforeAll(value = default_before_all) {
|
||||
const origin = beforeAll.ctx;
|
||||
Object.assign(origin, value);
|
||||
return origin;
|
||||
}
|
||||
|
||||
const mockLoopBackContext = (value = DEFAULT_LOOPBACK_CTX) => {
|
||||
const activeCtx = value;
|
||||
|
||||
const mockLoopBackContext = userId => {
|
||||
const activeCtx = default_loopback_ctx(userId);
|
||||
beforeAll(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
return activeCtx;
|
||||
};
|
||||
module.exports = {
|
||||
|
|
|
@ -4,7 +4,7 @@ describe('Application execute()/executeProc()/executeFunc()', () => {
|
|||
const userWithoutPrivileges = 1;
|
||||
const userWithInheritedPrivileges = 120;
|
||||
let tx;
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
beforeEach(async() => {
|
||||
tx = await models.Application.beginTransaction({});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Model crud()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
let insertId;
|
||||
const barcodeModel = app.models.ItemBarcode;
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Model rewriteDbError()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should extend rewriteDbError properties to any model passed', () => {
|
||||
const exampleModel = models.ItemTag;
|
||||
|
|
|
@ -2,7 +2,7 @@ const app = require('vn-loopback/server/server');
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('claim filter()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should return 1 result filtering by id', async() => {
|
||||
const tx = await app.models.Claim.beginTransaction({});
|
||||
|
|
|
@ -1,18 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('claim regularizeClaim()', () => {
|
||||
const userId = 18;
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: userId},
|
||||
headers: {origin: 'http://localhost'}
|
||||
}
|
||||
};
|
||||
const ctx = beforeAll.mockLoopBackContext(userId);
|
||||
ctx.req.__ = (value, params) => {
|
||||
return params.nickname;
|
||||
};
|
||||
|
||||
const chatModel = models.Chat;
|
||||
const claimId = 1;
|
||||
const ticketId = 1;
|
||||
|
@ -40,10 +33,6 @@ describe('claim regularizeClaim()', () => {
|
|||
return await models.ClaimEnd.create(claimEnds, options);
|
||||
}
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
|
||||
it('should send a chat message with value "Trash" and then change claim state to resolved', async() => {
|
||||
const tx = await models.Claim.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
const i18n = require('i18n');
|
||||
describe('Update Claim', () => {
|
||||
let url;
|
||||
let claimStatesMap = {};
|
||||
beforeAll.mockLoopBackContext();
|
||||
beforeAll(async() => {
|
||||
mockLoopBackContext();
|
||||
const claimStates = await app.models.ClaimState.find();
|
||||
claimStatesMap = claimStates.reduce((acc, state) => ({...acc, [state.code]: state.id}), {});
|
||||
});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Update Claim', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
const newDate = Date.vnNew();
|
||||
const original = {
|
||||
ticketFk: 3,
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Client addressesPropagateRe', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should propagate the isEqualizated on both addresses of Mr Wayne' +
|
||||
' and set hasToInvoiceByAddress to false', async() => {
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Address createAddress', () => {
|
||||
const clientFk = 1101;
|
||||
|
@ -7,9 +6,7 @@ describe('Address createAddress', () => {
|
|||
const incotermsFk = 'FAS';
|
||||
const customAgentOneId = 1;
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw a non uee member error if no incoterms is defined', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Client Create', () => {
|
||||
const newAccount = {
|
||||
userName: 'deadpool',
|
||||
|
@ -16,9 +14,7 @@ describe('Client Create', () => {
|
|||
const newAccountWithoutEmail = JSON.parse(JSON.stringify(newAccount));
|
||||
delete newAccountWithoutEmail.email;
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it(`should not find deadpool as he's not created yet`, async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Client getCard()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should receive a formated card of Bruce Wayne', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client getDebt()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return the client debt', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client sendSms()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should now send a message and log it', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('client summary()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return a summary object containing data', async() => {
|
||||
const clientId = 1101;
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Address updateAddress', () => {
|
||||
const clientId = 1101;
|
||||
const addressId = 1;
|
||||
|
@ -14,9 +12,7 @@ describe('Address updateAddress', () => {
|
|||
}
|
||||
};
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw the non uee member error if no incoterms is defined', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('loopback model address', () => {
|
||||
let createdAddressId;
|
||||
const clientId = 1101;
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
afterAll(async() => {
|
||||
const client = await models.Client.findById(clientId);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('entry addFromPackaging()', () => {
|
||||
const supplier = 442;
|
||||
|
@ -7,9 +6,7 @@ describe('entry addFromPackaging()', () => {
|
|||
const yesterday = new Date(today);
|
||||
yesterday.setDate(today.getDate() - 1);
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should create an incoming travel', async() => {
|
||||
const ctx = {accessToken: {userId: 49}, args: {isTravelReception: true, supplier}};
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Buy editLatestsBuys()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should change the value of a given column for the selected buys', async() => {
|
||||
const tx = await models.Buy.beginTransaction({});
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('entry importBuysPreview()', () => {
|
||||
const entryId = 1;
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return the buys with the calculated packagingFk', async() => {
|
||||
const tx = await models.Entry.beginTransaction({});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('invoiceInDueDay new()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should correctly create a new due day', async() => {
|
||||
const userId = 9;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceIn clone()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceIn corrective()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('invoiceOut book()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
const invoiceOutId = 5;
|
||||
|
||||
it('should update the booked property', async() => {
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('upsertFixedPrice()', () => {
|
||||
const now = Date.vnNew();
|
||||
const fixedPriceId = 1;
|
||||
let originalFixedPrice;
|
||||
|
||||
beforeAll.mockLoopBackContext();
|
||||
beforeAll(async() => {
|
||||
originalFixedPrice = await models.FixedPrice.findById(fixedPriceId);
|
||||
mockLoopBackContext();
|
||||
});
|
||||
|
||||
it(`should toggle the hasMinPrice boolean if there's a minPrice and update the rest of the data`, async() => {
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('itemShelving getAlternative()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return a list of items without alternatives', async() => {
|
||||
const shelvingFk = 'HEJ';
|
||||
|
|
|
@ -3,7 +3,7 @@ const {models} = require('vn-loopback/server/server');
|
|||
describe('ItemShelving upsertItem()', () => {
|
||||
const warehouseFk = 1;
|
||||
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('item clone()', () => {
|
||||
let nextItemId;
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
beforeEach(async() => {
|
||||
let query = `SELECT i1.id + 1 as id FROM vn.item i1
|
||||
|
|
|
@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('item getBalance()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return the balance lines of a client type loses in which one has highlighted true', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('item new()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should create a new item, adding the name as a tag', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('regularize()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
const ctx = beforeAll.mockLoopBackContext(18);
|
||||
|
||||
it('should create a new ticket and add a line', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
const options = {transaction: tx};
|
||||
|
||||
try {
|
||||
const ctx = {req: {accessToken: {userId: 18}}};
|
||||
const itemId = 1;
|
||||
const warehouseId = 1;
|
||||
const quantity = 11;
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('item updateTaxes()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw an error if the taxClassFk is blank', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('tag onSubmit()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should delete a tag', async() => {
|
||||
const tx = await models.Item.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order addToOrder()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
const orderId = 8;
|
||||
it('should add a row to a given order', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const {mockLoopBackContext} = require('../../../../../../back/vn-jasmine');
|
||||
|
||||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order filter()', () => {
|
||||
let ctx;
|
||||
beforeAll(() => ctx = mockLoopBackContext());
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should call the filter method with a basic search', async() => {
|
||||
const myCtx = Object.assign({}, ctx);
|
||||
|
|
|
@ -2,7 +2,7 @@ const models = require('vn-loopback/server/server').models;
|
|||
const UserError = require('vn-loopback/util/user-error');
|
||||
|
||||
describe('order new()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should throw an error if the client isnt active', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('order newFromTicket()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should create a new order from an existing ticket', async() => {
|
||||
const tx = await models.Order.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('AgencyTerm createInvoiceIn()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
const rows = [
|
||||
{
|
||||
routeFk: 2,
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('route clone()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
const createdDate = Date.vnNew();
|
||||
it('should throw an error if the amount of ids pased to the clone function do no match the database', async() => {
|
||||
|
|
|
@ -3,7 +3,7 @@ const app = require('vn-loopback/server/server');
|
|||
describe('route guessPriority()', () => {
|
||||
const targetRouteId = 7;
|
||||
let routeTicketsToRestore;
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
afterAll(async() => {
|
||||
let restoreFixtures = [];
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('route updateWorkCenter()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
const routeId = 1;
|
||||
|
||||
it('should set the commission work center if the worker has workCenter', async() => {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('supplier consumption() filter', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return a list of entries from the supplier 2', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {}};
|
||||
const filter = {
|
||||
where: {
|
||||
supplierFk: 2
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('loopback model Supplier', () => {
|
||||
let supplierOne;
|
||||
let supplierTwo;
|
||||
|
||||
beforeAll.mockLoopBackContext();
|
||||
beforeAll(async() => {
|
||||
supplierOne = await models.Supplier.findById(1);
|
||||
supplierTwo = await models.Supplier.findById(442);
|
||||
mockLoopBackContext();
|
||||
});
|
||||
|
||||
describe('payMethodFk', () => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('expeditionState addExpeditionState()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should update the expedition states', async() => {
|
||||
const tx = await models.ExpeditionState.beginTransaction({});
|
||||
try {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket deleteExpeditions()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should delete the selected expeditions', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket moveExpeditions()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should move the selected expeditions to new ticket', async() => {
|
||||
const tx = await models.Expedition.beginTransaction({});
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('sale canEdit()', () => {
|
||||
const employeeId = 1;
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
describe('sale not exists', () => {
|
||||
it('should return error if sale not exists', async() => {
|
||||
|
|
|
@ -1,23 +1,11 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('Ticket cloning - clone function', () => {
|
||||
let ctx;
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
let options;
|
||||
let tx;
|
||||
|
||||
beforeEach(async() => {
|
||||
ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {}
|
||||
};
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: ctx.req
|
||||
});
|
||||
|
||||
options = {transaction: tx};
|
||||
tx = await models.Sale.beginTransaction({});
|
||||
options.transaction = tx;
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('sale deleteSales()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw an error if the ticket of the given sales is not editable', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
@ -13,14 +11,6 @@ describe('sale deleteSales()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
|
||||
const sales = [{id: 1, instance: 0}, {id: 2, instance: 1}];
|
||||
const ticketId = 2;
|
||||
|
||||
|
@ -41,13 +31,6 @@ describe('sale deleteSales()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const sale = await models.Sale.findOne({where: {id: 9}}, options);
|
||||
sale.id = null;
|
||||
const newSale = await models.Sale.create(sale, options);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('sale recalculatePrice()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should update the sale price', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
const sales = [
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('sale reserve()', () => {
|
||||
const ctx = {
|
||||
|
@ -10,9 +9,7 @@ describe('sale reserve()', () => {
|
|||
}
|
||||
};
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw an error if the ticket can not be modified', async() => {
|
||||
const tx = await models.Sale.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('sale updateConcept()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
const saleId = 25;
|
||||
|
||||
it('should throw if ID was undefined', async() => {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('ticket-request confirm()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it(`should throw an error if the item doesn't exist`, async() => {
|
||||
const tx = await models.TicketRequest.beginTransaction({});
|
||||
|
|
|
@ -1,29 +1,15 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('ticket-request deny()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return the denied ticket request', async() => {
|
||||
const tx = await models.TicketRequest.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'}
|
||||
},
|
||||
args: {id: 4, observation: 'my observation'},
|
||||
};
|
||||
|
||||
ctx.req.__ = value => {
|
||||
return value;
|
||||
};
|
||||
|
||||
ctx.args = {id: 4, observation: 'my observation'};
|
||||
const result = await models.TicketRequest.deny(ctx, options);
|
||||
|
||||
expect(result.id).toEqual(4);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Ticket cloning - clone function', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
const ticketId = 1;
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('ticket componentUpdate()', () => {
|
||||
const userID = 1101;
|
||||
const ctx = beforeAll.getCtx(1101);
|
||||
const ticketID = 11;
|
||||
const today = Date.vnNew();
|
||||
const tomorrow = Date.vnNew();
|
||||
|
@ -16,8 +15,8 @@ describe('ticket componentUpdate()', () => {
|
|||
let componentOfSaleEight;
|
||||
let componentValue;
|
||||
|
||||
beforeAll.mockLoopBackContext();
|
||||
beforeAll(async() => {
|
||||
mockLoopBackContext();
|
||||
const deliveryComponenet = await models.Component.findOne({where: {code: 'delivery'}});
|
||||
deliveryComponentId = deliveryComponenet.id;
|
||||
componentOfSaleSeven = `SELECT value
|
||||
|
@ -54,16 +53,7 @@ describe('ticket componentUpdate()', () => {
|
|||
isWithoutNegatives: false
|
||||
};
|
||||
|
||||
let ctx = {
|
||||
args: args,
|
||||
req: {
|
||||
accessToken: {userId: userID},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
ctx.args = args;
|
||||
await models.Ticket.componentUpdate(ctx, options);
|
||||
|
||||
[componentValue] = await models.SaleComponent.rawSql(componentOfSaleSeven, null, options);
|
||||
|
@ -103,16 +93,7 @@ describe('ticket componentUpdate()', () => {
|
|||
isWithoutNegatives: false
|
||||
};
|
||||
|
||||
const ctx = {
|
||||
args: args,
|
||||
req: {
|
||||
accessToken: {userId: userID},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
ctx.args = args;
|
||||
const observationTypeDelivery = await models.ObservationType.findOne({
|
||||
where: {code: 'delivery'}
|
||||
}, options);
|
||||
|
@ -142,6 +123,7 @@ describe('ticket componentUpdate()', () => {
|
|||
});
|
||||
|
||||
it('should change warehouse and without negatives', async() => {
|
||||
const ctx = beforeAll.getCtx(9);
|
||||
const tx = await models.SaleComponent.beginTransaction({});
|
||||
|
||||
try {
|
||||
|
@ -168,17 +150,7 @@ describe('ticket componentUpdate()', () => {
|
|||
option: 'renewPrices',
|
||||
isWithoutNegatives: true
|
||||
};
|
||||
|
||||
const ctx = {
|
||||
args: args,
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
ctx.args = args;
|
||||
|
||||
const oldTicket = await models.Ticket.findById(ticketID, null, options);
|
||||
|
||||
|
@ -200,6 +172,7 @@ describe('ticket componentUpdate()', () => {
|
|||
});
|
||||
|
||||
describe('componentUpdate() keepPrice', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should change shipped and keep price', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
|
@ -229,16 +202,7 @@ describe('ticket componentUpdate()', () => {
|
|||
keepPrice: true
|
||||
};
|
||||
|
||||
const ctx = {
|
||||
args: args,
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
ctx.args = args;
|
||||
|
||||
const beforeSale = await models.Sale.findById(saleId, null, options);
|
||||
await models.Ticket.componentUpdate(ctx, options);
|
||||
|
@ -282,16 +246,7 @@ describe('ticket componentUpdate()', () => {
|
|||
keepPrice: false
|
||||
};
|
||||
|
||||
const ctx = {
|
||||
args: args,
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost'},
|
||||
__: value => {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
};
|
||||
ctx.args = args;
|
||||
|
||||
const beforeSale = await models.Sale.findById(saleId, null, options);
|
||||
await models.Ticket.componentUpdate(ctx, options);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket filter()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return the tickets matching the filter', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {}};
|
||||
const filter = {order: 'id DESC'};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -31,11 +31,12 @@ describe('ticket filter()', () => {
|
|||
const today = Date.vnNew();
|
||||
today.setHours(23, 59, 59, 59);
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
||||
const args = {
|
||||
problems: true,
|
||||
from: yesterday,
|
||||
to: today
|
||||
}};
|
||||
};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -60,11 +61,12 @@ describe('ticket filter()', () => {
|
|||
const today = Date.vnNew();
|
||||
today.setHours(23, 59, 59, 59);
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {
|
||||
const args = {
|
||||
problems: false,
|
||||
from: yesterday,
|
||||
to: today
|
||||
}};
|
||||
};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -83,7 +85,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {problems: null}};
|
||||
const args = {problems: null};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -102,7 +105,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {orderFk: 11}};
|
||||
const args = {orderFk: 11};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
const firstRow = result[0];
|
||||
|
@ -123,7 +127,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: true}};
|
||||
const args = {pending: true};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -146,7 +151,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {pending: false}};
|
||||
const args = {pending: false};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
const firstRow = result[0];
|
||||
|
@ -167,11 +173,13 @@ describe('ticket filter()', () => {
|
|||
|
||||
it('should return the tickets from the worker team', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
const ctx = beforeAll.getCtx(18);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: true}};
|
||||
const args = {myTeam: true};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -185,12 +193,14 @@ describe('ticket filter()', () => {
|
|||
});
|
||||
|
||||
it('should return the tickets that are not from the worker team', async() => {
|
||||
const ctx = beforeAll.getCtx(18);
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {myTeam: false}};
|
||||
const args = {myTeam: false};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -204,12 +214,14 @@ describe('ticket filter()', () => {
|
|||
});
|
||||
|
||||
it('should return the tickets belonging to the collection id 1', async() => {
|
||||
const ctx = beforeAll.getCtx(18);
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 18}}, args: {collectionFk: 1}};
|
||||
const args = {collectionFk: 1};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -228,7 +240,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: true}};
|
||||
const args = {hasRoute: true};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -247,7 +260,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: false}};
|
||||
const args = {hasRoute: false};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -266,7 +280,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasRoute: null}};
|
||||
const args = {hasRoute: null};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -285,7 +300,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: true}};
|
||||
const args = {hasInvoice: true};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
@ -304,7 +320,8 @@ describe('ticket filter()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args: {hasInvoice: null}};
|
||||
const args = {hasInvoice: null};
|
||||
ctx.args = args;
|
||||
const filter = {};
|
||||
const result = await models.Ticket.filter(ctx, filter, options);
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('TicketFuture getTicketsAdvance()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
let tomorrow = Date.vnNew();
|
||||
|
@ -18,7 +19,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
warehouseFk: 1,
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -42,7 +43,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
isFullMovable: true
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -67,7 +68,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
isFullMovable: false
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(0);
|
||||
|
@ -92,7 +93,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
ipt: 'V'
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(5);
|
||||
|
@ -117,7 +118,7 @@ describe('TicketFuture getTicketsAdvance()', () => {
|
|||
tfIpt: 'V'
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsAdvance(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(5);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket getTicketsFuture()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
const today = Date.vnNew();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
|
||||
|
@ -16,7 +17,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
warehouseFk: 1,
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -40,7 +41,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
problems: true
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -65,7 +66,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
problems: false
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toEqual(0);
|
||||
|
@ -90,7 +91,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
problems: null
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -115,7 +116,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
state: 'OK'
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -140,7 +141,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
futureState: 'OK'
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -165,7 +166,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
ipt: null
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -190,7 +191,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
ipt: 'H'
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -215,7 +216,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
futureIpt: null
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -240,7 +241,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
futureIpt: 'H'
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -265,7 +266,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
id: 13
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
@ -290,7 +291,7 @@ describe('ticket getTicketsFuture()', () => {
|
|||
futureId: 12
|
||||
};
|
||||
|
||||
const ctx = {req: {accessToken: {userId: 9}}, args};
|
||||
ctx.args = args;
|
||||
const result = await models.Ticket.getTicketsFuture(ctx, options);
|
||||
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket isEditableOrThrow()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should throw an error as the ticket does not exist', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
let error;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket merge()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
const tickets = {
|
||||
originId: 13,
|
||||
destinationId: 12,
|
||||
|
@ -10,10 +10,6 @@ describe('ticket merge()', () => {
|
|||
workerFk: 1
|
||||
};
|
||||
|
||||
ctx.req.__ = value => {
|
||||
return value;
|
||||
};
|
||||
|
||||
it('should merge two tickets', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ const ForbiddenError = require('vn-loopback/util/forbiddenError');
|
|||
|
||||
describe('ticket recalculateComponents()', () => {
|
||||
const ticketId = 11;
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it('should update the ticket components', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('ticket sendSms()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should send a message and log it', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,17 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket setDeleted()', () => {
|
||||
const userId = 1106;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: userId},
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
});
|
||||
});
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should throw an error if the given ticket has a claim', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
|
@ -20,7 +11,6 @@ describe('ticket setDeleted()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {req: activeCtx};
|
||||
const ticketId = 16;
|
||||
|
||||
await models.Ticket.setDeleted(ctx, ticketId, options);
|
||||
|
@ -40,15 +30,6 @@ describe('ticket setDeleted()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost:5000'},
|
||||
}
|
||||
};
|
||||
ctx.req.__ = value => {
|
||||
return value;
|
||||
};
|
||||
const ticketId = 24;
|
||||
const [sectorCollectionBefore] = await models.Ticket.rawSql(
|
||||
`SELECT COUNT(*) numberRows
|
||||
|
@ -75,15 +56,6 @@ describe('ticket setDeleted()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost:5000'},
|
||||
}
|
||||
};
|
||||
ctx.req.__ = value => {
|
||||
return value;
|
||||
};
|
||||
const [ticketCollectionOld] = await models.Ticket.rawSql(
|
||||
`SELECT COUNT(*) numberRows
|
||||
FROM vn.ticketCollection`, [], options);
|
||||
|
@ -110,16 +82,6 @@ describe('ticket setDeleted()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'http://localhost:5000'},
|
||||
}
|
||||
};
|
||||
ctx.req.__ = value => {
|
||||
return value;
|
||||
};
|
||||
|
||||
const ticketId = 8;
|
||||
await models.Ticket.setDeleted(ctx, ticketId, options);
|
||||
|
||||
|
|
|
@ -2,14 +2,10 @@ const models = require('vn-loopback/server/server').models;
|
|||
const LoopBackContext = require('loopback-context');
|
||||
|
||||
describe('ticket state()', () => {
|
||||
const ctx = beforeAll.getCtx();
|
||||
const salesPersonId = 18;
|
||||
const employeeId = 1;
|
||||
const productionId = 49;
|
||||
const activeCtx = {
|
||||
accessToken: {userId: 9},
|
||||
__: value => value
|
||||
};
|
||||
const ctx = {req: activeCtx};
|
||||
const now = Date.vnNew();
|
||||
const sampleTicket = {
|
||||
shipped: now,
|
||||
|
@ -33,7 +29,7 @@ describe('ticket state()', () => {
|
|||
|
||||
beforeAll(async() => {
|
||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
||||
active: activeCtx
|
||||
active: ctx
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -45,7 +41,7 @@ describe('ticket state()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
activeCtx.accessToken.userId = salesPersonId;
|
||||
ctx.req.accessToken.userId = salesPersonId;
|
||||
|
||||
await models.Ticket.state(ctx, {ticketFk: 2, stateFk: 3}, options);
|
||||
|
||||
|
@ -66,7 +62,7 @@ describe('ticket state()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
activeCtx.accessToken.userId = employeeId;
|
||||
ctx.req.accessToken.userId = employeeId;
|
||||
|
||||
await models.Ticket.state(ctx, {ticketFk: 11, stateFk: 13}, options);
|
||||
|
||||
|
@ -88,7 +84,7 @@ describe('ticket state()', () => {
|
|||
|
||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||
|
||||
activeCtx.accessToken.userId = productionId;
|
||||
ctx.req.accessToken.userId = productionId;
|
||||
const stateOk = await models.State.findOne({where: {code: 'OK'}}, options);
|
||||
const params = {ticketFk: ticket.id, stateFk: stateOk.id};
|
||||
|
||||
|
@ -114,7 +110,7 @@ describe('ticket state()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||
activeCtx.accessToken.userId = salesPersonId;
|
||||
ctx.req.accessToken.userId = salesPersonId;
|
||||
const assignedState = await models.State.findOne({where: {code: 'PICKER_DESIGNED'}}, options);
|
||||
const paramsAssigned = {ticketFk: ticket.id, stateFk: assignedState.id, userFk: 1};
|
||||
const resAssigned = await models.Ticket.state(ctx, paramsAssigned, options);
|
||||
|
@ -125,7 +121,7 @@ describe('ticket state()', () => {
|
|||
expect(resAssigned.userFk).toBe(1);
|
||||
expect(resAssigned.id).toBeDefined();
|
||||
|
||||
activeCtx.accessToken.userId = productionId;
|
||||
ctx.req.accessToken.userId = productionId;
|
||||
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
||||
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
||||
|
@ -147,7 +143,7 @@ describe('ticket state()', () => {
|
|||
const options = {transaction: tx};
|
||||
|
||||
const ticket = await models.Ticket.create(sampleTicket, options);
|
||||
activeCtx.accessToken.userId = salesPersonId;
|
||||
ctx.req.accessToken.userId = salesPersonId;
|
||||
|
||||
const sampleSale = {
|
||||
ticketFk: ticket.id,
|
||||
|
@ -167,7 +163,7 @@ describe('ticket state()', () => {
|
|||
expect(resAssigned.userFk).toBe(1);
|
||||
expect(resAssigned.id).toBeDefined();
|
||||
|
||||
activeCtx.accessToken.userId = productionId;
|
||||
ctx.req.accessToken.userId = productionId;
|
||||
const packedState = await models.State.findOne({where: {code: 'PACKED'}}, options);
|
||||
const paramsPacked = {ticketFk: ticket.id, stateFk: packedState.id, userFk: salesPersonId};
|
||||
const resPacked = await models.Ticket.state(ctx, paramsPacked, options);
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('Ticket transferClient()', () => {
|
|||
const refundTicketId = 24;
|
||||
const clientId = 1;
|
||||
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
let options;
|
||||
let tx;
|
||||
beforeEach(async() => {
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('sale updateDiscount()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
const ctx = beforeAll.getCtx();
|
||||
beforeAll.mockLoopBackContext();
|
||||
const originalSaleId = 8;
|
||||
|
||||
it('should throw an error if no sales were selected', async() => {
|
||||
|
@ -14,13 +12,6 @@ describe('sale updateDiscount()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const ticketId = 11;
|
||||
const sales = [];
|
||||
const newDiscount = 10;
|
||||
|
@ -43,13 +34,6 @@ describe('sale updateDiscount()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const ticketId = 11;
|
||||
const sales = [1, 14];
|
||||
const newDiscount = 10;
|
||||
|
@ -72,13 +56,6 @@ describe('sale updateDiscount()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const ticketId = 1;
|
||||
const sales = [1];
|
||||
const newDiscount = 100;
|
||||
|
@ -96,17 +73,11 @@ describe('sale updateDiscount()', () => {
|
|||
|
||||
it('should update the discount if the salesPerson has mana and manaCode = "mana"', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
const ctx = beforeAll.getCtx(18);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 18},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const ticketId = 11;
|
||||
const sales = [originalSaleId];
|
||||
const newDiscount = 100;
|
||||
|
@ -141,17 +112,11 @@ describe('sale updateDiscount()', () => {
|
|||
|
||||
it('should update the discount if the salesPerson has mana and manaCode = "manaClaim"', async() => {
|
||||
const tx = await models.Ticket.beginTransaction({});
|
||||
const ctx = beforeAll.getCtx(18);
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 18},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const ticketId = 11;
|
||||
const sales = [originalSaleId];
|
||||
const newDiscount = 100;
|
||||
|
@ -190,13 +155,6 @@ describe('sale updateDiscount()', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {
|
||||
req: {
|
||||
accessToken: {userId: 9},
|
||||
headers: {origin: 'localhost:5000'},
|
||||
__: () => {}
|
||||
}
|
||||
};
|
||||
const ticketId = 11;
|
||||
const sales = [originalSaleId];
|
||||
const newDiscount = 100;
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('ticket model TicketTracking', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
let ticketTrackingId;
|
||||
|
||||
afterAll(async() => {
|
||||
|
|
|
@ -5,7 +5,7 @@ describe('Termograph createThermograph()', () => {
|
|||
const model = 'DISPOSABLE';
|
||||
const temperatureFk = 'COOL';
|
||||
const warehouseId = 1;
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
|
||||
it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => {
|
||||
const tx = await models.Thermograph.beginTransaction({});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Travel createThermograph()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
const travelId = 3;
|
||||
const currentUserId = 1102;
|
||||
const thermographId = '138350-0';
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Worker absences()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should get the absence calendar for a full year contract', async() => {
|
||||
const ctx = {req: {accessToken: {userId: 1106}}};
|
||||
const workerId = 1106;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('department getLeaves()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return the department and the childs containing the search value', async() => {
|
||||
let result = await models.Department.getLeaves(ctx, null, 'INFORMATICA');
|
||||
|
||||
|
|
|
@ -133,7 +133,8 @@ describe('Worker createAbsence()', () => {
|
|||
expect(error.message).toEqual(`Cannot add holidays on this day`);
|
||||
});
|
||||
|
||||
it(`should throw an error when adding a absence if the worker has hours recorded that day and not is a half absence`, async() => {
|
||||
it(`should throw an error when adding a absence if the worker ` +
|
||||
`has hours recorded that day and not is a half absence`, async() => {
|
||||
const ctx = {
|
||||
req: {accessToken: {userId: 19}},
|
||||
args: {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('worker mySubordinates()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should return an array of subordinates greather than 1', async() => {
|
||||
let result = await app.models.Worker.mySubordinates(ctx);
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
const {models} = require('vn-loopback/server/server');
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('Worker new', () => {
|
||||
const developerId = 9;
|
||||
|
@ -10,9 +9,7 @@ describe('Worker new', () => {
|
|||
let tx;
|
||||
let opts;
|
||||
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
describe('should return error', () => {
|
||||
beforeEach(async() => {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const app = require('vn-loopback/server/server');
|
||||
|
||||
describe('Agency getAgenciesWithWarehouse()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
const today = Date.vnNew();
|
||||
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} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
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,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('agency clone()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should clone a zone', async() => {
|
||||
const tx = await models.Zone.beginTransaction({});
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('zone exclusionGeo()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
const zoneId = 1;
|
||||
const today = Date.vnNew();
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('zone getEvents()', () => {
|
||||
const {ctx} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
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} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
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} = beforeAll;
|
||||
const ctx = beforeAll.getCtx();
|
||||
it('should check returns data', async() => {
|
||||
const tx = await models.Zone.beginTransaction({});
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
const {mockLoopBackContext} = require('vn-loopback/../../back/vn-jasmine');
|
||||
|
||||
describe('zone toggleIsIncluded()', () => {
|
||||
beforeAll(() =>
|
||||
mockLoopBackContext()
|
||||
);
|
||||
beforeAll.mockLoopBackContext();
|
||||
|
||||
it('should return the created location with isIncluded true', async() => {
|
||||
const tx = await models.Zone.beginTransaction({});
|
||||
|
|
Loading…
Reference in New Issue