#1435 unitarios back hasActiveRecovery
gitea/salix/dev This commit looks good Details

This commit is contained in:
Carlos Jimenez Ruiz 2019-06-11 08:54:03 +02:00
parent 0c9b4bbe87
commit a8b9e2c374
2 changed files with 17 additions and 2 deletions

View File

@ -24,8 +24,8 @@ module.exports = Self => {
Self.hasActiveRecovery = async id => {
let result = await Self.rawSql(
`SELECT count(*) AS hasActiveRecovery
FROM vn.recovery
WHERE clientFk = ?
FROM vn.recovery
WHERE clientFk = ?
AND IFNULL(finished,CURDATE()) >= CURDATE();`,
[id]
);

View File

@ -0,0 +1,15 @@
const app = require('vn-loopback/server/server');
describe('client hasActiveRecovery', () => {
it(`should return false if the client doesn't owes`, async() => {
let hasActiveRecovery = await app.models.Recovery.hasActiveRecovery(101);
expect(hasActiveRecovery).toBeFalsy();
});
it('should return true if the client owes', async() => {
let hasActiveRecovery = await app.models.Recovery.hasActiveRecovery(102);
expect(hasActiveRecovery).toBeTruthy();
});
});