refactor: refs #6436 user-config and some sections tests
gitea/salix/pipeline/pr-dev This commit looks good
Details
gitea/salix/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
parent
bd45352215
commit
665d03f048
|
@ -1,12 +1,12 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('userConfig getUserConfig()', () => {
|
describe('userConfig getUserConfig()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it(`should return the configuration data of a given user`, async() => {
|
it(`should return the configuration data of a given user`, async() => {
|
||||||
const tx = await models.Item.beginTransaction({});
|
const tx = await models.Item.beginTransaction({});
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const result = await models.UserConfig.getUserConfig(ctx, options);
|
const result = await models.UserConfig.getUserConfig(ctx, options);
|
||||||
|
|
||||||
expect(result.warehouseFk).toEqual(1);
|
expect(result.warehouseFk).toEqual(1);
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('Client getCard()', () => {
|
describe('Client getCard()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should receive a formated card of Bruce Wayne', async() => {
|
it('should receive a formated card of Bruce Wayne', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const id = 1101;
|
const id = 1101;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('client getDebt()', () => {
|
describe('client getDebt()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should return the client debt', async() => {
|
it('should return the client debt', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('client sendSms()', () => {
|
describe('client sendSms()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should now send a message and log it', async() => {
|
it('should now send a message and log it', async() => {
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const id = 1101;
|
const id = 1101;
|
||||||
const destination = 222222222;
|
const destination = 222222222;
|
||||||
const message = 'this is the message created in a test';
|
const message = 'this is the message created in a test';
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('client summary()', () => {
|
describe('client summary()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should return a summary object containing data', async() => {
|
it('should return a summary object containing data', async() => {
|
||||||
const clientId = 1101;
|
const clientId = 1101;
|
||||||
const tx = await models.Client.beginTransaction({});
|
const tx = await models.Client.beginTransaction({});
|
||||||
|
|
|
@ -1,13 +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');
|
||||||
const activeCtx = {accessToken: {userId: 9}};
|
|
||||||
|
|
||||||
describe('entry importBuysPreview()', () => {
|
describe('entry importBuysPreview()', () => {
|
||||||
const entryId = 1;
|
const entryId = 1;
|
||||||
beforeAll(async() => {
|
beforeAll(async() => {
|
||||||
spyOn(LoopBackContext, 'getCurrentContext').and.returnValue({
|
mockLoopBackContext();
|
||||||
active: activeCtx
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return the buys with the calculated packagingFk', async() => {
|
it('should return the buys with the calculated packagingFk', async() => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('invoiceOut book()', () => {
|
describe('invoiceOut book()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
const invoiceOutId = 5;
|
const invoiceOutId = 5;
|
||||||
|
|
||||||
it('should update the booked property', async() => {
|
it('should update the booked property', async() => {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('order addToOrder()', () => {
|
describe('order addToOrder()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
const orderId = 8;
|
const orderId = 8;
|
||||||
it('should add a row to a given order', async() => {
|
it('should add a row to a given order', async() => {
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('order filter()', () => {
|
describe('order filter()', () => {
|
||||||
const ctx = {
|
const {ctx} = beforeAll;
|
||||||
req: {accessToken: {userId: 9}},
|
|
||||||
args: {},
|
|
||||||
params: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
it('should call the filter method with a basic search', async() => {
|
it('should call the filter method with a basic search', async() => {
|
||||||
const myCtx = Object.assign({}, ctx);
|
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');
|
const UserError = require('vn-loopback/util/user-error');
|
||||||
|
|
||||||
describe('order new()', () => {
|
describe('order new()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should throw an error if the client isnt active', async() => {
|
it('should throw an error if the client isnt active', async() => {
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('order newFromTicket()', () => {
|
describe('order newFromTicket()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should create a new order from an existing ticket', async() => {
|
it('should create a new order from an existing ticket', async() => {
|
||||||
const tx = await models.Order.beginTransaction({});
|
const tx = await models.Order.beginTransaction({});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('expeditionState addExpeditionState()', () => {
|
describe('expeditionState addExpeditionState()', () => {
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
it('should update the expedition states', async() => {
|
it('should update the expedition states', async() => {
|
||||||
const tx = await models.ExpeditionState.beginTransaction({});
|
const tx = await models.ExpeditionState.beginTransaction({});
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const models = require('vn-loopback/server/server').models;
|
const models = require('vn-loopback/server/server').models;
|
||||||
|
|
||||||
describe('sale recalculatePrice()', () => {
|
describe('sale recalculatePrice()', () => {
|
||||||
|
const {ctx} = beforeAll;
|
||||||
it('should update the sale price', async() => {
|
it('should update the sale price', async() => {
|
||||||
const tx = await models.Sale.beginTransaction({});
|
const tx = await models.Sale.beginTransaction({});
|
||||||
const sales = [
|
const sales = [
|
||||||
|
@ -10,7 +11,6 @@ describe('sale recalculatePrice()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const response = await models.Sale.recalculatePrice(ctx, sales, options);
|
const response = await models.Sale.recalculatePrice(ctx, sales, options);
|
||||||
|
|
||||||
expect(response[0].affectedRows).toBeDefined();
|
expect(response[0].affectedRows).toBeDefined();
|
||||||
|
@ -30,7 +30,6 @@ describe('sale recalculatePrice()', () => {
|
||||||
try {
|
try {
|
||||||
const options = {transaction: tx};
|
const options = {transaction: tx};
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const immutableSale = [{id: 1, ticketFk: 1}];
|
const immutableSale = [{id: 1, ticketFk: 1}];
|
||||||
await models.Sale.recalculatePrice(ctx, immutableSale, options);
|
await models.Sale.recalculatePrice(ctx, immutableSale, options);
|
||||||
|
|
||||||
|
|
|
@ -1,12 +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('sale updateConcept()', () => {
|
describe('sale updateConcept()', () => {
|
||||||
beforeAll(async() => {
|
const {ctx} = beforeAll;
|
||||||
mockLoopBackContext();
|
|
||||||
});
|
|
||||||
|
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
|
||||||
const saleId = 25;
|
const saleId = 25;
|
||||||
|
|
||||||
it('should throw if ID was undefined', async() => {
|
it('should throw if ID was undefined', async() => {
|
||||||
|
|
|
@ -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-request deny()', () => {
|
describe('ticket-request deny()', () => {
|
||||||
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 return the denied ticket request', async() => {
|
it('should return the denied ticket request', async() => {
|
||||||
|
|
|
@ -5,7 +5,7 @@ describe('Termograph createThermograph()', () => {
|
||||||
const model = 'DISPOSABLE';
|
const model = 'DISPOSABLE';
|
||||||
const temperatureFk = 'COOL';
|
const temperatureFk = 'COOL';
|
||||||
const warehouseId = 1;
|
const warehouseId = 1;
|
||||||
const ctx = {req: {accessToken: {userId: 9}}};
|
const {ctx} = beforeAll;
|
||||||
|
|
||||||
it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => {
|
it(`should create a thermograph which is saved in both thermograph and travelThermograph`, async() => {
|
||||||
const tx = await models.Thermograph.beginTransaction({});
|
const tx = await models.Thermograph.beginTransaction({});
|
||||||
|
|
Loading…
Reference in New Issue