Skip to content

Commit

Permalink
more robust limit/offset tx api integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
vekexasia committed Jun 4, 2018
1 parent 8afd28f commit 341ca9e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions tests/integration/api/transactions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,23 @@ describe('api/transactions', () => {
});
});
describe('limit and offset', () => {
beforeEach(async () => {
await createRandomAccountWithFunds(Math.pow(10, 11));
await createRandomAccountWithFunds(Math.pow(10, 11));
await createRandomAccountWithFunds(Math.pow(10, 11));
});
it('should limit ret txs by limit and offset it', async () => {
const {count, transactions} = await supertest(initializer.appManager.expressApp).get(`/api/transactions?type=${TransactionType.SEND}`)
const {count, transactions} = await supertest(initializer.appManager.expressApp).get(`/api/transactions?type=${TransactionType.SEND}&orderBy=height:desc`)
.then((resp) => resp.body);
// offset!
await supertest(initializer.appManager.expressApp).get(`/api/transactions?type=${TransactionType.SEND}&offset=1`)
await supertest(initializer.appManager.expressApp).get(`/api/transactions?type=${TransactionType.SEND}&offset=1&orderBy=height:desc`)
.then((resp) => {
expect(resp.body.count).to.be.eq(count);
expect(resp.body.transactions[0]).to.be.deep.eq(transactions[1]);
});

// limit and offset
await supertest(initializer.appManager.expressApp).get(`/api/transactions?type=${TransactionType.SEND}&offset=2&limit=1`)
await supertest(initializer.appManager.expressApp).get(`/api/transactions?type=${TransactionType.SEND}&offset=2&limit=1&orderBy=height:desc`)
.then((resp) => {
expect(resp.body.count).to.be.eq(count);
expect(resp.body.transactions.length).to.be.eq(1);
Expand Down

0 comments on commit 341ca9e

Please sign in to comment.