36 lines
1.6 KiB
JavaScript
36 lines
1.6 KiB
JavaScript
|
const app = require('vn-loopback/server/server');
|
||
|
|
||
|
describe('ticket editableStates()', () => {
|
||
|
it('should call the editableStates method with the production role and check that the result contain the DELIVERED state', async() => {
|
||
|
const ctx = {req: {accessToken: {userId: 49}}};
|
||
|
let result = await app.models.State.editableStates(ctx);
|
||
|
let codeExists = result.some(state => state.code == 'DELIVERED');
|
||
|
|
||
|
expect(codeExists).toBeTruthy();
|
||
|
});
|
||
|
|
||
|
it(`should call the editableStates method with the salesPerson role and check that the result not contain the DELIVERED state`, async() => {
|
||
|
const ctx = {req: {accessToken: {userId: 18}}};
|
||
|
let result = await app.models.State.editableStates(ctx);
|
||
|
let codeExists = result.some(state => state.code == 'DELIVERED');
|
||
|
|
||
|
expect(codeExists).toBeFalsy();
|
||
|
});
|
||
|
|
||
|
it(`should call the editableStates method with the salesPerson role and check that the result contain the PICKER_DESIGNED state`, async() => {
|
||
|
const ctx = {req: {accessToken: {userId: 18}}};
|
||
|
let result = await app.models.State.editableStates(ctx);
|
||
|
let codeExists = result.some(state => state.code == 'PICKER_DESIGNED');
|
||
|
|
||
|
expect(codeExists).toBeTruthy();
|
||
|
});
|
||
|
|
||
|
it(`should call the editableStates method with the employee role and check that the result not contain the PICKER_DESIGNED state`, async() => {
|
||
|
const ctx = {req: {accessToken: {userId: 1}}};
|
||
|
let result = await app.models.State.editableStates(ctx);
|
||
|
let codeExists = result.some(state => state.code == 'PICKER_DESIGNED');
|
||
|
|
||
|
expect(codeExists).toBeFalsy();
|
||
|
});
|
||
|
});
|