This commit is contained in:
parent
251d71a437
commit
330fb08aac
|
@ -1,15 +1,24 @@
|
|||
const models = require('vn-loopback/server/server').models;
|
||||
|
||||
describe('Client transactions', () => {
|
||||
const ctx = {};
|
||||
|
||||
it('should call transactions() method to receive a list of Web Payments from BRUCE WAYNE', async() => {
|
||||
const tx = await models.Client.beginTransaction({});
|
||||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {};
|
||||
const filter = {where: {clientFk: 1101}};
|
||||
const result = await models.Client.transactions(ctx, filter, options);
|
||||
const result = await models.Client.transactions(
|
||||
ctx,
|
||||
filter,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
options
|
||||
);
|
||||
|
||||
expect(result[1].id).toBeTruthy();
|
||||
|
||||
|
@ -26,9 +35,17 @@ describe('Client transactions', () => {
|
|||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {args: {orderFk: 6}};
|
||||
const filter = {};
|
||||
const result = await models.Client.transactions(ctx, filter, options);
|
||||
const result = await models.Client.transactions(
|
||||
ctx,
|
||||
filter,
|
||||
6,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
options
|
||||
);
|
||||
|
||||
const firstRow = result[0];
|
||||
|
||||
|
@ -47,10 +64,17 @@ describe('Client transactions', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
|
||||
const ctx = {args: {amount: 40}};
|
||||
const filter = {};
|
||||
const result = await models.Client.transactions(ctx, filter, options);
|
||||
const result = await models.Client.transactions(
|
||||
ctx,
|
||||
filter,
|
||||
undefined,
|
||||
undefined,
|
||||
40,
|
||||
undefined,
|
||||
undefined,
|
||||
options
|
||||
);
|
||||
|
||||
const randomIndex = Math.floor(Math.random() * result.length);
|
||||
const transaction = result[randomIndex];
|
||||
|
@ -69,14 +93,30 @@ describe('Client transactions', () => {
|
|||
|
||||
try {
|
||||
const options = {transaction: tx};
|
||||
const ctx = {args: {from: '2000/12/31'}};
|
||||
const filter = {};
|
||||
const withResults = await models.Client.transactions(ctx, filter, options);
|
||||
const withResults = await models.Client.transactions(
|
||||
ctx,
|
||||
filter,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'2000/12/31',
|
||||
undefined,
|
||||
options
|
||||
);
|
||||
|
||||
expect(withResults.length).toEqual(6);
|
||||
|
||||
ctx.args.from = '2099/12/31';
|
||||
const noResults = await models.Client.transactions(ctx, filter, options);
|
||||
const noResults = await models.Client.transactions(
|
||||
ctx,
|
||||
filter,
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
'2099/12/31',
|
||||
undefined,
|
||||
options
|
||||
);
|
||||
|
||||
expect(noResults.length).toEqual(0);
|
||||
|
||||
|
|
Loading…
Reference in New Issue