salix/services/loopback/common/methods/client/specs/activeWorkersWithRole.spec.js

24 lines
848 B
JavaScript

const app = require(`${servicesDir}/client/server/server`);
describe('Client activeWorkersWithRole', () => {
it('should return the sales people as result', async () => {
let filter = {where: {role: 'salesPerson'}};
let result = await app.models.Client.activeWorkersWithRole(filter);
let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson');
expect(result.length).toEqual(10);
expect(isSalesPerson).toBeTruthy();
});
it('should return the buyers as result', async () => {
let filter = {where: {role: 'buyer'}};
let result = await app.models.Client.activeWorkersWithRole(filter);
let isBuyer = await app.models.Account.hasRole(result[0].id, 'buyer');
expect(result.length).toEqual(9);
expect(isBuyer).toBeTruthy();
});
});