All files / apps/mc/src/sections data.ts

100% Statements 16/16
100% Branches 3/3
100% Functions 4/4
100% Lines 15/15

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 26 27 28 29 30 31  6x     6x 4x     4x 1x   1x 1x     1x   4x   4x 2x 1x     2x   4x   4x    
import { Hero, ModularSet, Scenario } from "../@models";
import { createSection, createTitle } from "../helper";
 
// eslint-disable-next-line max-params
export const loadData = (body: HTMLBodyElement, heroes: Hero[], modules: ModularSet[], scenarios: Scenario[]): void => {
    createTitle("Data", body);
 
    // display heroes
    const heroesData = heroes.map((hero) => {
        hero.name = `${hero.name}`;
 
        if (null != hero.aspects) {
            hero.name = `${hero.name} (${hero.aspects.join("/")})`;
        }
 
        return hero;
    });
    createSection("Heroes", heroesData, body);
    // display Scenarios
    const scenariosData = scenarios.map((scenario) => {
        scenario.name = `${scenario.name} (${
            null != scenario.modularSets ? scenario.modularSets.map((modularSet) => modularSet.name).join(", ") : ""
        })`;
 
        return scenario;
    });
    createSection("Scenarios", scenariosData, body);
    // display Modular sets
    createSection("Modular Encounter Sets", modules, body);
};