mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-07 22:15:45 +01:00
Context sensitive search (#2102)
Extend global search to search context-sensitive in repositories and namespaces.
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user