2021-07-08 13:53:30 +00:00
|
|
|
const models = require('vn-loopback/server/server').models;
|
2018-01-19 12:05:25 +00:00
|
|
|
|
2018-01-19 12:07:03 +00:00
|
|
|
describe('Greuge totalGreuge()', () => {
|
2018-04-03 14:10:39 +00:00
|
|
|
it('should call the sumAmount method', async() => {
|
2021-07-08 13:53:30 +00:00
|
|
|
const tx = await models.Client.beginTransaction({});
|
2018-01-19 12:05:25 +00:00
|
|
|
|
2021-07-08 13:53:30 +00:00
|
|
|
try {
|
|
|
|
const options = {transaction: tx};
|
2018-01-23 08:33:23 +00:00
|
|
|
|
2021-08-12 08:55:04 +00:00
|
|
|
const clientId = 1101;
|
2021-07-08 13:53:30 +00:00
|
|
|
|
2021-08-12 08:55:04 +00:00
|
|
|
const result = await models.Greuge.sumAmount(clientId, options);
|
2021-07-08 13:53:30 +00:00
|
|
|
|
2021-08-12 08:55:04 +00:00
|
|
|
expect(result).toBe(203.71);
|
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
|
|
|
}
|
2018-01-19 12:05:25 +00:00
|
|
|
});
|
|
|
|
});
|