UNPKG

@sinchsmb/ui-kit

Version:

UI kit for SinchSMB frontend

29 lines (25 loc) 676 B
export function makeTestId<T extends string | undefined>(rootId: T, subComponentId: string): T; export function makeTestId<T extends string | undefined>( rootId: T, subComponentId: string, subComponentModifier: string, ): T; /** * Return string that should be used as testId. * * Format will be `rootId__subComponentId--subComponentModifier`. */ export function makeTestId( rootId?: string, subComponentId?: string, subComponentModifier?: string, ): string | unknown { if (!rootId) { return undefined; } let id = `${rootId}__${subComponentId}`; if (subComponentModifier !== undefined) { id += `--${subComponentModifier}`; } return id; }