All files / app/codeCharta/state/effects/updateFileSettings/utils blacklist.merger.ts

90.9% Statements 10/11
50% Branches 2/4
100% Functions 1/1
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 262x     2x 4x   4x       4x 8x 8x 8x           8x       4x    
import { getUpdatedBlacklistItemPath } from "../../../../util/nodePathHelper"
import { BlacklistItem, CCFile } from "../../../../codeCharta.model"
 
export function getMergedBlacklist(inputFiles: CCFile[], withUpdatedPath: boolean) {
    const blacklist: Map<string, BlacklistItem> = new Map()
 
    Iif (inputFiles.length === 1) {
        return inputFiles[0].settings.fileSettings.blacklist
    }
 
    for (const inputFile of inputFiles) {
        if (inputFile.settings.fileSettings.blacklist) {
            for (const oldBlacklistItem of inputFile.settings.fileSettings.blacklist) {
                const blacklistItem: BlacklistItem = {
                    path: withUpdatedPath
                        ? getUpdatedBlacklistItemPath(inputFile.fileMeta.fileName, oldBlacklistItem.path)
                        : oldBlacklistItem.path,
                    type: oldBlacklistItem.type
                }
                blacklist.set(`${blacklistItem.path}|${blacklistItem.type}`, blacklistItem)
            }
        }
    }
    return [...blacklist.values()]
}