Update Current Navigation to version 1.1.4 with new features and improvements
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
buildCurrentNavigationItems, getLocalProperty, parseBoolean, resolveTermUrl, selectCurrentNavigationRoot
|
||||
buildCurrentNavigationItems, getLocalProperty, normalizeRootWebPath, parseBoolean, resolveTermUrl,
|
||||
selectCurrentNavigationRoot
|
||||
} from '../src/services/CurrentNavigationCore';
|
||||
import { ICurrentNavigationTerm } from '../src/services/CurrentNavigationTypes';
|
||||
|
||||
@@ -33,6 +34,8 @@ const root: ICurrentNavigationTerm = selectCurrentNavigationRoot(
|
||||
terms, 'https://portal/sites/portal/hr', 'https://portal/sites/portal'
|
||||
);
|
||||
assert('root is selected through its site home URL', !!root && root.Id === 'root');
|
||||
assert('site home URL is normalized to its web',
|
||||
normalizeRootWebPath('/sites/portal/hr/SitePages/Home.aspx') === '/sites/portal/hr');
|
||||
const items = buildCurrentNavigationItems(terms, root, 'https://portal/sites/portal', 1031, 3, false);
|
||||
assert('root is not rendered by default', items.length === 1 && items[0].id === 'docs');
|
||||
assert('descendants are nested', items[0].items.length === 1 && items[0].items[0].id === 'forms');
|
||||
@@ -44,4 +47,40 @@ const unordered = buildCurrentNavigationItems(
|
||||
);
|
||||
assert('hierarchy is independent of taxonomy response order',
|
||||
unordered.length === 1 && unordered[0].id === 'docs' && unordered[0].items[0].id === 'forms');
|
||||
|
||||
const inheritedTerms: ICurrentNavigationTerm[] = [
|
||||
term({ Id: 'kits', Name: 'KITS', PathOfTerm: 'Organisation;CIR;KITS', LocalCustomProperties: {
|
||||
'CurrentNavigation.Root': 'true',
|
||||
'_Sys_Nav_SimpleLinkUrl': 'http://dhs.contoso.local/organisation/cir/CIR_3/'
|
||||
}}),
|
||||
term({ Id: 'team', Name: 'Team SharePoint', PathOfTerm: 'Organisation;CIR;KITS;Team SharePoint',
|
||||
LocalCustomProperties: {
|
||||
'TopNavigation.Hidden': 'true',
|
||||
'_Sys_Nav_SimpleLinkUrl': 'http://dhs.contoso.local/organisation/cir/CIR_13/'
|
||||
}}),
|
||||
term({ Id: 'games', Name: 'Spielewiese', PathOfTerm: 'Organisation;CIR;KITS;Team SharePoint;Spielewiese',
|
||||
LocalCustomProperties: {
|
||||
'_Sys_Nav_SimpleLinkUrl': 'http://dhs.contoso.local/organisation/cir/CIR_21/'
|
||||
}})
|
||||
];
|
||||
const inheritedRoot: ICurrentNavigationTerm = selectCurrentNavigationRoot(
|
||||
inheritedTerms,
|
||||
'http://dhs.contoso.local/organisation/cir/CIR_21/',
|
||||
'http://dhs.contoso.local/organisation/cir'
|
||||
);
|
||||
assert('nearest taxonomy ancestor root applies to a web with a generic URL',
|
||||
!!inheritedRoot && inheritedRoot.Id === 'kits');
|
||||
const teamRoot: ICurrentNavigationTerm = selectCurrentNavigationRoot(
|
||||
inheritedTerms,
|
||||
'http://dhs.contoso.local/organisation/cir/CIR_13/',
|
||||
'http://dhs.contoso.local/organisation/cir'
|
||||
);
|
||||
assert('taxonomy ancestor root also applies to the direct child web',
|
||||
!!teamRoot && teamRoot.Id === 'kits');
|
||||
const inheritedItems = buildCurrentNavigationItems(
|
||||
inheritedTerms, inheritedRoot, 'http://dhs.contoso.local/organisation/cir', 1031, 3, false
|
||||
);
|
||||
assert('top-navigation hidden does not hide current navigation terms',
|
||||
inheritedItems.length === 1 && inheritedItems[0].id === 'team' &&
|
||||
inheritedItems[0].items.length === 1 && inheritedItems[0].items[0].id === 'games');
|
||||
console.log('CurrentNavigation core tests passed:', passed);
|
||||
|
||||
Reference in New Issue
Block a user