Updated unit tests
This commit is contained in:
parent
6b8074e32f
commit
78313bd9a7
|
@ -1,23 +0,0 @@
|
||||||
const app = require('vn-loopback/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(19);
|
|
||||||
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(17);
|
|
||||||
expect(isBuyer).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('Worker activeWithInheritedRole', () => {
|
||||||
|
it('should return the workers with an inherited role of salesPerson', async() => {
|
||||||
|
const filter = {where: {role: 'salesPerson'}};
|
||||||
|
const result = await app.models.Worker.activeWithInheritedRole(filter);
|
||||||
|
|
||||||
|
const randomIndex = Math.floor(Math.random() * result.length);
|
||||||
|
const worker = result[randomIndex];
|
||||||
|
|
||||||
|
const isSalesPerson = await app.models.Account.hasRole(worker.id, 'salesPerson');
|
||||||
|
|
||||||
|
expect(result.length).toEqual(19);
|
||||||
|
expect(isSalesPerson).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the workers with an inherited role of buyer', async() => {
|
||||||
|
const filter = {where: {role: 'buyer'}};
|
||||||
|
const result = await app.models.Worker.activeWithInheritedRole(filter);
|
||||||
|
|
||||||
|
const randomIndex = Math.floor(Math.random() * result.length);
|
||||||
|
const worker = result[randomIndex];
|
||||||
|
|
||||||
|
const isBuyer = await app.models.Account.hasRole(worker.id, 'buyer');
|
||||||
|
|
||||||
|
expect(result.length).toEqual(17);
|
||||||
|
expect(isBuyer).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,21 @@
|
||||||
|
const app = require('vn-loopback/server/server');
|
||||||
|
|
||||||
|
describe('Worker activeWithRole', () => {
|
||||||
|
it('should return the sales people as result', async() => {
|
||||||
|
const filter = {where: {role: 'salesPerson'}};
|
||||||
|
const result = await app.models.Worker.activeWithRole(filter);
|
||||||
|
const firstWorker = result[0];
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
expect(firstWorker.nickname).toEqual('salesPersonNick');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return the buyers as result', async() => {
|
||||||
|
const filter = {where: {role: 'buyer'}};
|
||||||
|
const result = await app.models.Worker.activeWithRole(filter);
|
||||||
|
const firstWorker = result[0];
|
||||||
|
|
||||||
|
expect(result.length).toEqual(1);
|
||||||
|
expect(firstWorker.nickname).toEqual('buyerNick');
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue