<commit_before>#! /usr/bin/env yarn jest

import { ExplorerProgram, DecisionMatrix } from "./ExplorerProgram"
import { DefaultExplorerProgram } from "./DefaultExplorerProgram"
import { getRequiredChartIds } from "./ExplorerUtils"
import { GridBoolean } from "./GridGrammarConstants"

describe(ExplorerProgram, () => {
    const program = new ExplorerProgram("test", DefaultExplorerProgram)
    it("gets the required chart ids", () => {
        expect(program.requiredChartIds).toEqual([35])
    })

    it("gets code", () => {
        expect(program.decisionMatrixCode).toContain("chartId")
    })

    it("allows blank lines in blocks", () => {
        const code = `title\tData Explorer
switcher
\tchartId\tDevice Radio
\t35\tInternet

\t46\tMobile`
        expect(new ExplorerProgram("test", code).requiredChartIds).toEqual([
            35,
            46,
        ])
    })

    it("can detect errors", () => {
        const results = new ExplorerProgram("test", `titleTypo Foo`).getCell(
            0,
            0
        )
        expect(results.errorMessage).toEqual("")
        expect(results.options!.length).toBeGreaterThan(1)
    })
})

describe(DecisionMatrix, () => {
    const code = `chartId,country Radio,indicator Radio,interval Radio,perCapita Radio
21,usa,GDP,annual,${GridBoolean.false}
24,usa,GDP,annual,Per million
26,usa,GDP,monthly,
29,usa,Life expectancy,,
33,france,Life expectancy,,
55,spain,GDP,,${GridBoolean.false}
56,spain,GDP,,Per million`
    const options = new DecisionMatrix(code)

    it("starts with a selected chart", () => {
        expect(options.selectedRow.chartId).toEqual(21)
        expect(options.toObject().country).toEqual("usa")
        expect(options.toObject().indicator).toEqual("GDP")
    })

    it("it can get all options", () => {
        expect(options.allOptionsAsQueryStrings().length).toBe(7)
    })

    it("can detect needed chart configs", () => {<commit_msg>Fix: ctrl+s<commit_after>#! /usr/bin/env yarn jest

import { ExplorerProgram, DecisionMatrix } from "./ExplorerProgram"
import { DefaultExplorerProgram } from "./DefaultExplorerProgram"
import { getRequiredChartIds } from "./ExplorerUtils"
import { GridBoolean } from "./GridGrammarConstants"

describe(ExplorerProgram, () => {
    const program = new ExplorerProgram("test", DefaultExplorerProgram)
    it("gets the required chart ids", () => {
        expect(program.requiredChartIds).toEqual([35])
    })

    it("gets code", () => {
        expect(program.decisionMatrixCode).toContain("chartId")
    })

    it("allows blank lines in blocks", () => {
        const code = `title\tData Explorer
switcher
\tchartId\tDevice Radio
\t35\tInternet

\t46\tMobile`
        expect(new ExplorerProgram("test", code).requiredChartIds).toEqual([
            35,
            46,
        ])
    })

    it("can detect errors", () => {
        const results = new ExplorerProgram("test", `titleTypo Foo`).getCell(
            0,
            0
        )
        expect(results.errorMessage).not.toEqual("")
        expect(results.options!.length).toBeGreaterThan(1)
    })
})

describe(DecisionMatrix, () => {
    const code = `chartId,country Radio,indicator Radio,interval Radio,perCapita Radio
21,usa,GDP,annual,${GridBoolean.false}
24,usa,GDP,annual,Per million
26,usa,GDP,monthly,
29,usa,Life expectancy,,
33,france,Life expectancy,,
55,spain,GDP,,${GridBoolean.false}
56,spain,GDP,,Per million`
    const options = new DecisionMatrix(code)

    it("starts with a selected chart", () => {
        expect(options.selectedRow.chartId).toEqual(21)
        expect(options.toObject().country).toEqual("usa")
        expect(options.toObject().indicator).toEqual("GDP")
    })

    it("it can get all options", () => {
        expect(options.allOptionsAsQueryStrings().length).toBe(7)
    })

    it("can detect needed chart configs", () => {
{'fraction_non_alphanumeric': 0.14756224066390042, 'fraction_numerical': 0.015560165975103735, 'mean_word_length': 3.490104772991851, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, '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': '7575055', 'n_tokens_mistral': 1225, 'n_tokens_neox': 1154, 'n_words': 221}