All files / app/codeCharta/state/effects/updateVisibleTopLabels getNumberOfTopLabels.ts

100% Statements 9/9
100% Branches 1/1
100% Functions 1/1
100% Lines 8/8

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 1314x   14x 14x   14x 7x 7x 4x   3x    
import { defaultAmountOfTopLabels } from "../../store/appSettings/amountOfTopLabels/amountOfTopLabels.reducer"
 
const BUILDINGS_PER_LABEL = 100
const MAX_NUMBER_OF_LABELS = 10
 
export const getNumberOfTopLabels = (codeMapNodes: { length: number }) => {
    const numberOfLabels = Math.floor(codeMapNodes.length / BUILDINGS_PER_LABEL)
    if (numberOfLabels <= defaultAmountOfTopLabels) {
        return defaultAmountOfTopLabels
    }
    return Math.min(numberOfLabels, MAX_NUMBER_OF_LABELS)
}