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}}}; let result = await app.models.State.editableStates(ctx); let deliveredState = result.some(state => state.code == 'DELIVERED'); expect(deliveredState).toBeTruthy(); }); it(`should returns 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); 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); let pickerDesignedState = result.some(state => state.code == 'PICKER_DESIGNED'); expect(pickerDesignedState).toBeFalsy(); }); });