35 lines
1.4 KiB
JavaScript
35 lines
1.4 KiB
JavaScript
const app = require('vn-loopback/server/server');
|
|
|
|
describe('ticket editableStates()', () => {
|
|
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}}};
|
|
|
|
let result = await app.models.State.editableStates(ctx, filter);
|
|
let deliveredState = result.some(state => state.code == 'DELIVERED');
|
|
|
|
expect(deliveredState).toBeTruthy();
|
|
});
|
|
|
|
it(`should return the expected states by a specific role`, async() => {
|
|
const productionRole = 18;
|
|
const ctx = {req: {accessToken: {userId: productionRole}}};
|
|
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');
|
|
|
|
expect(deliveredState).toBeFalsy();
|
|
expect(pickerDesignedState).toBeTruthy();
|
|
});
|
|
|
|
it(`should return again the expected state by a specific role`, async() => {
|
|
const employeeRole = 1;
|
|
const ctx = {req: {accessToken: {userId: employeeRole}}};
|
|
let result = await app.models.State.editableStates(ctx, filter);
|
|
let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED');
|
|
|
|
expect(pickerDesignedState).toBeTruthy();
|
|
});
|
|
});
|