2021-07-08 13:53:30 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2019-06-11 06:54:03 +00:00
|
|
|
|
|
|
|
describe('client hasActiveRecovery', () => {
|
|
|
|
it(`should return false if the client doesn't owes`, async() => {
|
2021-07-08 13:53:30 +00:00
|
|
|
const tx = await models.Client.beginTransaction({});
|
2019-06-11 06:54:03 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
|
|
|
const hasActiveRecovery = await models.Recovery.hasActiveRecovery(1101, options);
|
|
|
|
|
|
|
|
expect(hasActiveRecovery).toBeFalsy();
|
|
|
|
|
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
2021-08-12 08:55:04 +00:00
|
|
|
throw e;
|
2021-07-08 13:53:30 +00:00
|
|
|
}
|
2019-06-11 06:54:03 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should return true if the client owes', async() => {
|
2021-07-08 13:53:30 +00:00
|
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
|
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
|
|
|
|
|
|
|
const hasActiveRecovery = await models.Recovery.hasActiveRecovery(1102, options);
|
|
|
|
|
|
|
|
expect(hasActiveRecovery).toBeTruthy();
|
2019-06-11 06:54:03 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
await tx.rollback();
|
|
|
|
} catch (e) {
|
|
|
|
await tx.rollback();
|
2021-08-12 08:55:04 +00:00
|
|
|
throw e;
|
2021-07-08 13:53:30 +00:00
|
|
|
}
|
2019-06-11 06:54:03 +00:00
|
|
|
});
|
|
|
|
});
|