Skip to content

Commit

Permalink
✅ add first page condition when search submit
Browse files Browse the repository at this point in the history
(cherry picked from commit 0442302)
  • Loading branch information
hugo-escire authored and Zahraa Chreim committed Apr 24, 2024
1 parent c311e9e commit e24c8e3
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 e24c8e3

Please sign in to comment.