tests fixed

This commit is contained in:
Gerard 2018-11-27 13:23:51 +01:00
parent 78ac80ad72
commit 11c5240834
4 changed files with 24 additions and 27 deletions

View File

@ -24,7 +24,7 @@ module.exports = Self => {
Self.activeWorkersWithRole = async filter => { Self.activeWorkersWithRole = async filter => {
let conn = Self.dataSource.connector; let conn = Self.dataSource.connector;
if (filter.where.and && Array.isArray(filter.where.and)) { if (filter.where && filter.where.and && Array.isArray(filter.where.and)) {
let where = {}; let where = {};
filter.where.and.forEach(element => { filter.where.and.forEach(element => {
where[Object.keys(element)[0]] = Object.values(element)[0]; where[Object.keys(element)[0]] = Object.values(element)[0];

View File

@ -1,13 +0,0 @@
const app = require(`${servicesDir}/client/server/server`);
describe('Client activeBuyer', () => {
it('should return the buyers as result', async () => {
let filter = {};
let result = await app.models.Client.activeBuyer(filter);
let isBuyer = await app.models.Account.hasRole(result[0].id, 'buyer');
expect(result.length).toEqual(9);
expect(isBuyer).toBeTruthy();
});
});

View File

@ -1,13 +0,0 @@
const app = require(`${servicesDir}/client/server/server`);
describe('Client activeSalesPerson', () => {
it('should return the sales people as result', async () => {
let filter = {};
let result = await app.models.Client.activeSalesPerson(filter);
let isSalesPerson = await app.models.Account.hasRole(result[0].id, 'salesPerson');
expect(result.length).toEqual(10);
expect(isSalesPerson).toBeTruthy();
});
});

View File

@ -0,0 +1,23 @@
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();
});
});