Skip to content

Commit

Permalink
fix non-integer page numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryPotdevin committed Apr 7, 2016
1 parent a85637c commit 1a4df90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/__test__/core/query/ImmutableQuerySpec.ts
Expand Up @@ -210,6 +210,9 @@ describe("ImmutableQuery", ()=> {
expect(query.getPage()).toEqual(1)
query = query.setFrom(60)
expect(query.getPage()).toEqual(4)
// Page should always be an integer
query = query.setFrom(50)
expect(query.getPage()).toEqual(3) // floor(3.5)
})

it("setHighlight()", ()=> {
Expand Down
2 changes: 1 addition & 1 deletion src/core/query/ImmutableQuery.ts
Expand Up @@ -146,7 +146,7 @@ export class ImmutableQuery {
}

getPage(){
return 1 + (this.getFrom()||0) / (this.getSize()||10)
return 1 + Math.floor((this.getFrom()||0) / (this.getSize()||10))
}

deepUpdate(key, ob){
Expand Down

0 comments on commit 1a4df90

Please sign in to comment.