1
0

w2p-85346 Allow facets to be authority controlled and add test to verify

This commit is contained in:
Nathan Buckingham
2021-12-03 10:54:41 -05:00
parent 9fc7b57157
commit 768de1a1e7
3 changed files with 20 additions and 0 deletions

View File

@@ -24,6 +24,12 @@ export class FacetValue implements HALResource {
@autoserialize
count: number;
/**
* The Authority Value for this facet
*/
@autoserialize
authorityKey?: string;
/**
* The {@link HALLink}s for this FacetValue
*/

View File

@@ -12,6 +12,7 @@ describe('Search Utils', () => {
let facetValueWithSearchHref: FacetValue;
let facetValueWithoutSearchHref: FacetValue;
let searchFilterConfig: SearchFilterConfig;
let facetValueWithSearchHrefAuthority: FacetValue;
beforeEach(() => {
facetValueWithSearchHref = Object.assign(new FacetValue(), {
@@ -22,6 +23,11 @@ describe('Search Utils', () => {
}
}
});
facetValueWithSearchHrefAuthority = Object.assign(new FacetValue(), {
value: 'Value with search href',
authorityKey: 'uuid',
}
);
facetValueWithoutSearchHref = Object.assign(new FacetValue(), {
value: 'Value without search href'
});
@@ -34,6 +40,10 @@ describe('Search Utils', () => {
expect(getFacetValueForType(facetValueWithSearchHref, searchFilterConfig)).toEqual('Value with search href,operator');
});
it('should retrieve the correct value from the Facet', () => {
expect(getFacetValueForType(facetValueWithSearchHrefAuthority, searchFilterConfig)).toEqual('uuid,authority');
});
it('should return the facet value with an equals operator by default', () => {
expect(getFacetValueForType(facetValueWithoutSearchHref, searchFilterConfig)).toEqual('Value without search href,equals');
});

View File

@@ -16,6 +16,10 @@ export function getFacetValueForType(facetValue: FacetValue, searchFilterConfig:
return values[1];
}
}
if (facetValue.authorityKey) {
return addOperatorToFilterValue(facetValue.authorityKey, 'authority');
}
return addOperatorToFilterValue(facetValue.value, 'equals');
}