22541 expand breadcrumb route-state helpers for label and dns path reuse
This commit is contained in:
@@ -11,7 +11,7 @@ const loadRouteStateModule = () => {
|
||||
|
||||
source = source.replace(/export const\s+/g, "const ");
|
||||
source +=
|
||||
"\nmodule.exports = { normalizeRouteStateQuery, resolveSearchResultsHref };\n";
|
||||
"\nmodule.exports = { normalizeRouteStateQuery, resolveSearchResultsHref, resolveSearchBreadcrumbLabel, isDnsRoutePath };\n";
|
||||
|
||||
const context = {
|
||||
module: { exports: {} },
|
||||
@@ -116,6 +116,48 @@ test("routing/routeState supports DNS route override", async () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("routing/routeState resolves breadcrumb label using key and route flags", async () => {
|
||||
const mod = loadRouteStateModule();
|
||||
const getViewAllLabel = (key) =>
|
||||
({ myCases: "My Cases", watchedCases: "Watched Cases" })[key] || null;
|
||||
|
||||
const fromViewAll = mod.resolveSearchBreadcrumbLabel({
|
||||
query: { va: "true", key: "myCases" },
|
||||
getViewAllLabel,
|
||||
advancedLabel: "Advanced",
|
||||
addressLabel: "Address",
|
||||
defaultLabel: "Search"
|
||||
});
|
||||
const fromAdvanced = mod.resolveSearchBreadcrumbLabel({
|
||||
query: { adv: "true" },
|
||||
getViewAllLabel,
|
||||
advancedLabel: "Advanced",
|
||||
addressLabel: "Address",
|
||||
defaultLabel: "Search"
|
||||
});
|
||||
const fromDefault = mod.resolveSearchBreadcrumbLabel({
|
||||
query: {},
|
||||
getViewAllLabel,
|
||||
advancedLabel: "Advanced",
|
||||
addressLabel: "Address",
|
||||
defaultLabel: "Search"
|
||||
});
|
||||
|
||||
assert.strictEqual(fromViewAll, "My Cases");
|
||||
assert.strictEqual(fromAdvanced, "Advanced");
|
||||
assert.strictEqual(fromDefault, "Search");
|
||||
});
|
||||
|
||||
test("routing/routeState identifies dns and myportal dns route prefixes", async () => {
|
||||
const mod = loadRouteStateModule();
|
||||
|
||||
assert.strictEqual(mod.isDnsRoutePath("/dns"), true);
|
||||
assert.strictEqual(mod.isDnsRoutePath("/dns/development"), true);
|
||||
assert.strictEqual(mod.isDnsRoutePath("/myportal/dns"), true);
|
||||
assert.strictEqual(mod.isDnsRoutePath("/myportal/dns/applications"), true);
|
||||
assert.strictEqual(mod.isDnsRoutePath("/case/123"), false);
|
||||
});
|
||||
|
||||
const run = async () => {
|
||||
let passed = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user