<commit_before>import fs from 'fs';
import ReportGenerator from 'lighthouse/report/generator/report-generator';
import lighthouseBadges, {
  htmlReportsToFile,
  metricsToSvg,
  processRawLighthouseResult,
} from '../src/lighthouse-badges';
import { zip } from '../src/util';
import { parser } from '../src/argparser';
import reportFixture from '../assets/report/emanuelemazzotta.com.json';

describe('test lighthouse badges', () => {
  describe('the lighthouse command results are processed as expected', () => {
    it('should return correct metrics and no report', async () => {
      const url = 'https://emanuelemazzotta.com';
      const shouldSaveReport = false;
      const result = await processRawLighthouseResult(
        reportFixture, url, shouldSaveReport,
      );
      expect({
        metrics: {
          'lighthouse performance': 98,
          'lighthouse pwa': 85,
          'lighthouse accessibility': 100,
          'lighthouse best-practices': 93,
          'lighthouse seo': 100,
        },
        report: {
          [url]: false,
        },
      }).toStrictEqual(result);
    });

    it('should return correct metrics and a valid report', async () => {
      const expectedHtmlReport = ReportGenerator.generateReportHtml(reportFixture);
      const url = 'https://emanuelemazzotta.com';
      const shouldSaveReport = true;
      const result = await processRawLighthouseResult(
        reportFixture, url, shouldSaveReport,
      );
      expect({
        metrics: {
          'lighthouse performance': 98,
          'lighthouse pwa': 85,
          'lighthouse accessibility': 100,
          'lighthouse best-practices': 93,
          'lighthouse seo': 100,
        },
        report: {
          [url]: expectedHtmlReport,
        },
      }).toStrictEqual(result);
    });
  });

  describe('the html reports are saved correctly', () => {
    let output;
    const { writeFile } = fs;

    beforeEach(() => {
      output = [];<commit_msg>Fix test lint<commit_after>import fs from 'fs';
import ReportGenerator from 'lighthouse/report/generator/report-generator';
import lighthouseBadges, {
  htmlReportsToFile,
  metricsToSvg,
  processRawLighthouseResult,
} from '../src/lighthouse-badges';
import { zip } from '../src/util';
import { parser } from '../src/argparser';
import reportFixture from '../assets/report/emanuelemazzotta.com.json';

describe('test lighthouse badges', () => {
  describe('the lighthouse command results are processed as expected', () => {
    it('should return correct metrics and no report', async () => {
      const url = 'https://emanuelemazzotta.com';
      const shouldSaveReport = false;
      const result = await processRawLighthouseResult(reportFixture, url, shouldSaveReport);
      expect({
        metrics: {
          'lighthouse performance': 98,
          'lighthouse pwa': 85,
          'lighthouse accessibility': 100,
          'lighthouse best-practices': 93,
          'lighthouse seo': 100,
        },
        report: {
          [url]: false,
        },
      }).toStrictEqual(result);
    });

    it('should return correct metrics and a valid report', async () => {
      const expectedHtmlReport = ReportGenerator.generateReportHtml(reportFixture);
      const url = 'https://emanuelemazzotta.com';
      const shouldSaveReport = true;
      const result = await processRawLighthouseResult(reportFixture, url, shouldSaveReport);
      expect({
        metrics: {
          'lighthouse performance': 98,
          'lighthouse pwa': 85,
          'lighthouse accessibility': 100,
          'lighthouse best-practices': 93,
          'lighthouse seo': 100,
        },
        report: {
          [url]: expectedHtmlReport,
        },
      }).toStrictEqual(result);
    });
  });

  describe('the html reports are saved correctly', () => {
    let output;
    const { writeFile } = fs;

    beforeEach(() => {
      output = [];
{'fraction_non_alphanumeric': 0.1248081841432225, 'fraction_numerical': 0.012276214833759591, 'mean_word_length': 2.658559401309635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2860617', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1061, 'n_words': 278}