2019-08-08 06:33:27 +00:00
|
|
|
const app = require('vn-loopback/server/server');
|
|
|
|
|
|
|
|
describe('ticket editableStates()', () => {
|
2019-08-12 10:31:31 +00:00
|
|
|
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);
|
2019-08-12 10:31:31 +00:00
|
|
|
let deliveredState = result.some(state => state.code == 'DELIVERED');
|
2019-08-08 06:33:27 +00:00
|
|
|
|
2019-08-12 10:31:31 +00:00
|
|
|
expect(deliveredState).toBeTruthy();
|
2019-08-08 06:33:27 +00:00
|
|
|
});
|
|
|
|
|
2019-08-12 10:31:31 +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);
|
2019-08-12 10:31:31 +00:00
|
|
|
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
|
|
|
|
2019-08-12 10:31:31 +00:00
|
|
|
expect(deliveredState).toBeFalsy();
|
|
|
|
expect(pickerDesignedState).toBeTruthy();
|
2019-08-08 06:33:27 +00:00
|
|
|
});
|
|
|
|
|
2019-08-12 10:31:31 +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);
|
2019-08-12 10:31:31 +00:00
|
|
|
let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED');
|
2019-08-08 06:33:27 +00:00
|
|
|
|
2019-08-12 10:31:31 +00:00
|
|
|
expect(pickerDesignedState).toBeFalsy();
|
2019-08-08 06:33:27 +00:00
|
|
|
});
|
|
|
|
});
|