112 lines
3.1 KiB
JavaScript
112 lines
3.1 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('Client isValidClient', () => {
|
|
it('should call the isValidClient() method with a client id and receive true', async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const id = 1101;
|
|
const result = await models.Client.isValidClient(id, options);
|
|
|
|
expect(result).toBeTruthy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should call the isValidClient() method with an employee id to receive false', async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const id = 1;
|
|
const result = await models.Client.isValidClient(id, options);
|
|
|
|
expect(result).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should call the isValidClient() method with an unexistant id and receive false', async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const id = 999;
|
|
const result = await models.Client.isValidClient(id, options);
|
|
|
|
expect(result).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should call the isValidClient() method with an invalid id and receive false', async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const id = 'Pepinillos';
|
|
const result = await models.Client.isValidClient(id, options);
|
|
|
|
expect(result).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should call the isValidClient() method with a customer id which isnt active and return false', async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const id = '1106';
|
|
const result = await models.Client.isValidClient(id, options);
|
|
|
|
expect(result).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should call the isValidClient() method with a customer id which his data isnt verified and return false', async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const id = '110';
|
|
const result = await models.Client.isValidClient(id, options);
|
|
|
|
expect(result).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|