Context sensitive search (#2102)

Extend global search to search context-sensitive in repositories and namespaces.
This commit is contained in:
Eduard Heimbuch
2022-08-04 11:29:05 +02:00
parent 6c82142643
commit 550ebefd93
34 changed files with 1061 additions and 308 deletions

View File

@@ -22,7 +22,13 @@
* SOFTWARE.
*/
import { concat, getNamespaceAndPageFromMatch, getQueryStringFromLocation, withEndingSlash } from "./urls";
import {
concat,
getNamespaceAndPageFromMatch,
getQueryStringFromLocation,
getValueStringFromLocationByKey,
withEndingSlash,
} from "./urls";
describe("tests for withEndingSlash", () => {
it("should append missing slash", () => {
@@ -102,3 +108,28 @@ describe("tests for getQueryStringFromLocation", () => {
expect(getQueryStringFromLocation(location)).toBeUndefined();
});
});
describe("tests for getValueStringFromLocationByKey", () => {
function createLocation(search: string) {
return {
search,
};
}
it("should return the value string", () => {
const location = createLocation("?name=abc");
expect(getValueStringFromLocationByKey(location, "name")).toBe("abc");
});
it("should return value string from multiple parameters", () => {
const location = createLocation("?x=a&y=b&q=abc&z=c");
expect(getValueStringFromLocationByKey(location, "x")).toBe("a");
expect(getValueStringFromLocationByKey(location, "y")).toBe("b");
expect(getValueStringFromLocationByKey(location, "z")).toBe("c");
});
it("should return undefined if q is not available", () => {
const location = createLocation("?x=a&y=b&z=c");
expect(getValueStringFromLocationByKey(location, "namespace")).toBeUndefined();
});
});