mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 15:33:04 +00:00
78991: Also test SearchOptions.fixedFilter
This commit is contained in:
@@ -13,6 +13,7 @@ describe('PaginatedSearchOptions', () => {
|
||||
new SearchFilter('f.example', ['another value', 'second value']),
|
||||
new SearchFilter('f.range', ['[2002 TO 2021]'], 'equals'),
|
||||
];
|
||||
const fixedFilter = 'f.fixed=1234 5678,equals';
|
||||
const query = 'search query';
|
||||
const scope = '0fde1ecb-82cc-425a-b600-ac3576d76b47';
|
||||
const baseUrl = 'www.rest.com';
|
||||
@@ -23,7 +24,8 @@ describe('PaginatedSearchOptions', () => {
|
||||
filters: filters,
|
||||
query: query,
|
||||
scope: scope,
|
||||
dsoTypes: [DSpaceObjectType.ITEM]
|
||||
dsoTypes: [DSpaceObjectType.ITEM],
|
||||
fixedFilter: fixedFilter,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -35,6 +37,7 @@ describe('PaginatedSearchOptions', () => {
|
||||
'sort=test.field,DESC&' +
|
||||
'page=0&' +
|
||||
'size=40&' +
|
||||
'f.fixed=1234%205678,equals&' +
|
||||
'query=search%20query&' +
|
||||
'scope=0fde1ecb-82cc-425a-b600-ac3576d76b47&' +
|
||||
'dsoType=ITEM&' +
|
||||
|
@@ -11,11 +11,18 @@ describe('SearchOptions', () => {
|
||||
new SearchFilter('f.example', ['another value', 'second value']),
|
||||
new SearchFilter('f.range', ['[2002 TO 2021]'], 'equals'),
|
||||
];
|
||||
const fixedFilter = 'f.fixed=1234 5678,equals';
|
||||
const query = 'search query';
|
||||
const scope = '0fde1ecb-82cc-425a-b600-ac3576d76b47';
|
||||
const baseUrl = 'www.rest.com';
|
||||
beforeEach(() => {
|
||||
options = new SearchOptions({ filters: filters, query: query, scope: scope, dsoTypes: [DSpaceObjectType.ITEM] });
|
||||
options = new SearchOptions({
|
||||
filters: filters,
|
||||
query: query,
|
||||
scope: scope,
|
||||
dsoTypes: [DSpaceObjectType.ITEM],
|
||||
fixedFilter: fixedFilter,
|
||||
});
|
||||
});
|
||||
|
||||
describe('when toRestUrl is called', () => {
|
||||
@@ -23,6 +30,7 @@ describe('SearchOptions', () => {
|
||||
it('should generate a string with all parameters that are present', () => {
|
||||
const outcome = options.toRestUrl(baseUrl);
|
||||
expect(outcome).toEqual('www.rest.com?' +
|
||||
'f.fixed=1234%205678,equals&' +
|
||||
'query=search%20query&' +
|
||||
'scope=0fde1ecb-82cc-425a-b600-ac3576d76b47&' +
|
||||
'dsoType=ITEM&' +
|
||||
|
@@ -45,7 +45,7 @@ export class SearchOptions {
|
||||
const match = this.fixedFilter.match(/^([^=]+=)(.+)$/);
|
||||
|
||||
if (match) {
|
||||
fixedFilter = match[1] + encodeURIComponent(match[2]);
|
||||
fixedFilter = match[1] + encodeURIComponent(match[2]).replace(/%2C/g, ',');
|
||||
} else {
|
||||
fixedFilter = encodeURIComponent(this.fixedFilter);
|
||||
}
|
||||
|
Reference in New Issue
Block a user