Skip to content

Commit

Permalink
✅ add first page condition when search submit
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo-escire committed Aug 25, 2023
1 parent 88a7088 commit 0442302
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/app/shared/search-form/search-form.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('SearchFormComponent', () => {
const searchService = new SearchServiceStub();
const paginationService = new PaginationServiceStub();
const searchConfigService = { paginationID: 'test-id' };
const firstPage = { 'spc.page': 1 };
const dspaceObjectService = {
findById: () => createSuccessfulRemoteDataObject$(undefined),
};
Expand Down Expand Up @@ -104,37 +105,37 @@ describe('SearchFormComponent', () => {
const scope = 'MCU';
let searchQuery = {};

it('should navigate to the search page even when no parameters are provided', () => {
it('should navigate to the search first page even when no parameters are provided', () => {
comp.updateSearch(searchQuery);

expect(router.navigate).toHaveBeenCalledWith(comp.getSearchLinkParts(), {
queryParams: searchQuery,
queryParams: { ...searchQuery, ...firstPage },
queryParamsHandling: 'merge'
});
});

it('should navigate to the search page with parameters only query if only query is provided', () => {
it('should navigate to the search first page with parameters only query if only query is provided', () => {
searchQuery = {
query: query
};

comp.updateSearch(searchQuery);

expect(router.navigate).toHaveBeenCalledWith(comp.getSearchLinkParts(), {
queryParams: searchQuery,
queryParams: { ...searchQuery, ...firstPage },
queryParamsHandling: 'merge'
});
});

it('should navigate to the search page with parameters only query if only scope is provided', () => {
it('should navigate to the search first page with parameters only query if only scope is provided', () => {
searchQuery = {
scope: scope
};

comp.updateSearch(searchQuery);

expect(router.navigate).toHaveBeenCalledWith(comp.getSearchLinkParts(), {
queryParams: searchQuery,
queryParams: {...searchQuery, ...firstPage},
queryParamsHandling: 'merge'
});
});
Expand Down

0 comments on commit 0442302

Please sign in to comment.