This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement dedicated reset page method (#673)
* feat(SearchParameters): implement resetPage * refactor: use resetPage rather than setPage * feat: emit change event with reset page information * refactor(change): use object vs list of arguments
- Loading branch information
Showing
8 changed files
with
234 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
const SearchParameters = require('../../../src/SearchParameters'); | ||
|
||
test('without a previous page it should return the given SearchParameters', () => { | ||
const parameters = new SearchParameters(); | ||
const parametersWithPageReseted = parameters.resetPage(); | ||
|
||
expect(parameters).toBe(parametersWithPageReseted); | ||
expect(parametersWithPageReseted.page).toBeUndefined(); | ||
}); | ||
|
||
test('with a previous page of 0 it should return the given SearchParameters', () => { | ||
const parameters = new SearchParameters({ | ||
page: 0 | ||
}); | ||
|
||
const parametersWithPageReseted = parameters.resetPage(); | ||
|
||
expect(parameters).toBe(parametersWithPageReseted); | ||
expect(parametersWithPageReseted.page).toBe(0); | ||
}); | ||
|
||
|
||
test('with a previous page it should set the page to 0', () => { | ||
const parameters = new SearchParameters({ | ||
page: 5 | ||
}); | ||
|
||
const parametersWithPageReseted = parameters.resetPage(); | ||
|
||
expect(parameters).not.toBe(parametersWithPageReseted); | ||
expect(parametersWithPageReseted.page).toBe(0); | ||
}); |
Oops, something went wrong.