salix/modules/ticket/back/methods/state/specs/editableState.spec.js

35 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-08-08 06:33:27 +00:00
const app = require('vn-loopback/server/server');
describe('ticket editableStates()', () => {
2020-03-26 11:00:07 +00:00
const filter = {where: {name: {like: '%%'}}};
it('should return the expected state for the given role', async() => {
const productionRole = 49;
const ctx = {req: {accessToken: {userId: productionRole}}};
2020-03-26 11:00:07 +00:00
let result = await app.models.State.editableStates(ctx, filter);
let deliveredState = result.some(state => state.code == 'DELIVERED');
2019-08-08 06:33:27 +00:00
expect(deliveredState).toBeTruthy();
2019-08-08 06:33:27 +00:00
});
2020-10-15 16:57:27 +00:00
it(`should return the expected states by a specific role`, async() => {
const productionRole = 18;
const ctx = {req: {accessToken: {userId: productionRole}}};
2020-03-26 11:00:07 +00:00
let result = await app.models.State.editableStates(ctx, filter);
let deliveredState = result.some(state => state.code == 'DELIVERED');
let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED');
2019-08-08 06:33:27 +00:00
expect(deliveredState).toBeFalsy();
expect(pickerDesignedState).toBeTruthy();
2019-08-08 06:33:27 +00:00
});
it(`should return again the expected state by a specific role`, async() => {
const employeeRole = 1;
const ctx = {req: {accessToken: {userId: employeeRole}}};
2020-03-26 11:00:07 +00:00
let result = await app.models.State.editableStates(ctx, filter);
let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED');
2019-08-08 06:33:27 +00:00
2020-09-25 12:50:04 +00:00
expect(pickerDesignedState).toBeTruthy();
2019-08-08 06:33:27 +00:00
});
});