38 lines
1.0 KiB
JavaScript
38 lines
1.0 KiB
JavaScript
const models = require('vn-loopback/server/server').models;
|
|
|
|
describe('client hasActiveRecovery', () => {
|
|
it(`should return false if the client doesn't owes`, async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const hasActiveRecovery = await models.Recovery.hasActiveRecovery(1101, options);
|
|
|
|
expect(hasActiveRecovery).toBeFalsy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
|
|
it('should return true if the client owes', async() => {
|
|
const tx = await models.Client.beginTransaction({});
|
|
|
|
try {
|
|
const options = {transaction: tx};
|
|
|
|
const hasActiveRecovery = await models.Recovery.hasActiveRecovery(1102, options);
|
|
|
|
expect(hasActiveRecovery).toBeTruthy();
|
|
|
|
await tx.rollback();
|
|
} catch (e) {
|
|
await tx.rollback();
|
|
throw e;
|
|
}
|
|
});
|
|
});
|