Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge branch 'release/3.0.0' of https://github.com/LiskHQ/lisk-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
shuse2 committed Jan 17, 2020
2 parents 06fb17c + c7baa4b commit b3cb6c8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions elements/lisk-api-client/src/resources/delegates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ export class DelegatesResource extends APIResource {

this.get = apiMethod({
defaultData: {
sort: 'username:asc',
sort: 'voteWeight:desc',
},
method: GET,
}).bind(this);

this.getStandby = apiMethod({
defaultData: {
offset: 101,
sort: 'username:asc',
sort: 'voteWeight:desc',
},
method: GET,
}).bind(this);
Expand Down
4 changes: 3 additions & 1 deletion framework/src/modules/http_api/schema/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ paths:
- missedBlocks:desc
- producedBlocks:asc
- producedBlocks:desc
default: username:asc
- voteWeight:asc
- voteWeight:desc
default: voteWeight:desc
responses:
200:
description: Search results matching criteria
Expand Down
22 changes: 22 additions & 0 deletions framework/test/mocha/functional/http/get/delegates.js
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,28 @@ describe('GET /delegates', () => {
});
});

it('using sort="voteWeight:asc" should sort results in ascending order', async () => {
return delegatesEndpoint
.makeRequest({ sort: 'voteWeight:asc' }, 200)
.then(res => {
expect(_.map(res.data, 'voteWeight').sort()).to.eql(
_.map(res.data, 'voteWeight'),
);
});
});

it('using sort="voteWeight:desc" should sort results in descending order', async () => {
return delegatesEndpoint
.makeRequest({ sort: 'voteWeight:desc' }, 200)
.then(res => {
expect(
_.map(res.data, 'voteWeight')
.sort()
.reverse(),
).to.eql(_.map(res.data, 'voteWeight'));
});
});

it('using sort with any of sort fields should not place NULLs first', async () => {
const delegatesSortFields = [
'username',
Expand Down

0 comments on commit b3cb6c8

Please sign in to comment.