import { normalizeAccount, normalizeCacheMinutes, normalizeMaxDepth, normalizeMaxPeople, normalizeProfileUrl, profileProperty, uniqueAccounts } from '../src/webparts/organizationChart/OrganizationChartCore'; import { IUserProfileProperty } from '../src/webparts/organizationChart/OrganizationChartTypes'; declare const console: { log(message: string): void }; let passed: number = 0; function assert(condition: boolean, message: string): void { if (!condition) { throw new Error(message); } passed++; } const properties: IUserProfileProperty[] = [ { Key: 'Department', Value: 'IT' }, { Key: 'Manager', Value: 'CONTOSO\\manager' } ]; assert(normalizeAccount(' CONTOSO\\user ') === 'CONTOSO\\user', 'Account must be trimmed.'); assert(profileProperty(properties, 'department') === 'IT', 'Profile-property lookup must ignore casing.'); assert(profileProperty(properties, 'Office') === '', 'Missing profile properties must be empty.'); assert(uniqueAccounts(['A', 'a', 'B', 'C'], 'B', 10).join(',') === 'A,C', 'Accounts must be unique and excludable.'); assert(normalizeMaxDepth(0) === 6 && normalizeMaxDepth(20) === 10, 'Tree depth must be constrained.'); assert(normalizeMaxPeople(1) === 10 && normalizeMaxPeople(900) === 500, 'Person count must be constrained.'); assert(normalizeCacheMinutes(-1) === 0 && normalizeCacheMinutes(300) === 120, 'Cache duration must be constrained.'); assert(normalizeProfileUrl('javascript:alert(1)', 'http://portal') === '', 'Unsafe profile URLs must be rejected.'); assert(normalizeProfileUrl('/my/person.aspx', 'http://portal') === '/my/person.aspx', 'Server-relative URLs must be retained.'); console.log('Organization chart core tests passed: ' + passed);