All files / src/reporter csv.js

80% Statements 8/10
50% Branches 2/4
100% Functions 1/1
80% Lines 8/10

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 231x 1x   1x 1x     1x             1x 1x         1x    
const {getComplementaryGESInfo, getComplementaryWaterInfo} = require("../utils");
const fs = require('fs');
 
module.exports =  (result, options) => {
    const rows = [["Métrique", "Valeur", "Informations complémentaires"].join(',')]
 
 
    rows.push(...[
        ["EcoIndex", result.ecoIndex + '/100', ''].join(','),
        ["Note", result.grade, ''].join(','),
        ["GES", result.greenhouseGasesEmission + 'eqCO2', getComplementaryGESInfo(result.greenhouseGasesEmission, options)].join(','),
        ["Eau", result.waterConsumption + 'cl', getComplementaryWaterInfo(result.waterConsumption, options)].join(',')
    ]);
 
    const formattedCSV = rows.join('\n').toString()
    Iif(options.outputPath && options.outputPathDir){
        fs.mkdirSync(options.outputPathDir, { recursive: true });
        fs.writeFileSync(options.outputPath, formattedCSV);
    }
 
    console.log(formattedCSV);
}