export function formatTag(text: string): string {
    return "@" + text.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, (match, index) => {
        if (+match === 0) return ""; // Remove non-alphanumeric characters
        return index === 0 ? match.toLowerCase() : match.toUpperCase();
    });
}
/**
 * @description - Use this to add calculated/standardized/randomized tags to scenarioData prior to running. Randomly adds a smoke tag to 1 of the testCases.
 * @param scenarioData - the data from your test case
 * @returns scenarioData, but with added tags.
 */

export function getRandomTestName(scenarioData: any) : string {
    const testCaseNames: string[] = Object.keys(scenarioData);
    const totalKeys = testCaseNames.length
    const randomIndex = Math.floor(Math.random() * totalKeys) - 1;
    const randomKey = testCaseNames[randomIndex];

    return randomKey;
}

export function metaTags(currentTestName: string, randomTestName: string) : string [] {
    return currentTestName == randomTestName ? ["@smoke", "@standardRegression"] : ["@standardRegression"]
}

export function matchAndReplaceContactDataTag(data: string[], replacement: string): string[] {
    return data.map((value) => value.replace(/[{]{2}contact[}]{2}/, replacement));
}

export function matchAndReplaceAccountDataTag(data: string[], replacement: string): string[] {
    return data.map((value) => value.replace(/[{]{2}account[}]{2}/, replacement));
}
