Fix failing test by only preserving credential_type

- Reset `defaults` object’s own `credential_type` value to that of
`queryset`’s.
This commit is contained in:
kialam 2018-06-04 12:05:18 -04:00
parent 99ea28c3fd
commit b344eb9af0

View File

@ -235,15 +235,15 @@ function SmartSearchController (
};
$scope.clearAllTerms = () => {
const cleared = {};
_.forOwn(defaults, function(value, key) {
if (key !== "page") {
cleared[key] = _.has(queryset, key) ? queryset[key] : value;
_.forOwn(defaults, (value, key) => {
// preserve the `credential_type` queryset param if it exists
if (key === 'credential_type') {
defaults[key] = queryset[key];
}
});
queryset = _(cleared).omit(_.isNull).value();
const cleared = _(defaults).omit(_.isNull).value();
delete cleared.page;
queryset = cleared;
if (!$scope.querySet) {
$state.go('.', { [searchKey]: queryset });