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

33 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-08-08 06:33:27 +00:00
const app = require('vn-loopback/server/server');
describe('ticket editableStates()', () => {
it('should return the expected state for the given role', async() => {
const productionRole = 49;
const ctx = {req: {accessToken: {userId: productionRole}}};
2019-08-08 06:33:27 +00:00
let result = await app.models.State.editableStates(ctx);
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
});
it(`should returns the expected states by a specific role`, async() => {
const productionRole = 18;
const ctx = {req: {accessToken: {userId: productionRole}}};
2019-08-08 06:33:27 +00:00
let result = await app.models.State.editableStates(ctx);
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}}};
2019-08-08 06:33:27 +00:00
let result = await app.models.State.editableStates(ctx);
let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED');
2019-08-08 06:33:27 +00:00
expect(pickerDesignedState).toBeFalsy();
2019-08-08 06:33:27 +00:00
});
});