26:    // one created by parseArray(), so an empty CD cell must
180:                // This is done to match parseArray() behavior.
import buildMathMLOrig from "../src/buildMathML";
import parseTreeOrig from "../src/parseTree";
import Options from "../src/Options";
import Settings from "../src/Settings";
import Style from "../src/Style";

// TODO(ts)
const buildMathML: any = buildMathMLOrig;
const parseTree: any = parseTreeOrig;

const getMathML = function(expr: any, settings: any = new Settings()) {
    let startStyle = Style.TEXT;
    if (settings.displayMode) {
        startStyle = Style.DISPLAY;
    }

    // Setup the default options
    const options = new Options({
        style: startStyle,
        maxSize: Infinity,
        minRuleThickness: 0,
    });

    const built = buildMathML(parseTree(expr, settings), expr, options,
        settings.displayMode);

    // Strip off the surrounding <span>
    return built.children[0].toMarkup();
};

describe("A MathML builder", function() {
    it('should generate the right types of nodes', () => {
        expect(getMathML("\\sin{x}+1\\;\\text{a}")).toMatchSnapshot();
    });

    it('should concatenate digits into single <mn>', () => {
        expect(getMathML("\\sin{\\alpha}=0.34=.34^1")).toMatchSnapshot();
        expect(getMathML("1{,}000{,}000")).toMatchSnapshot();
    });

    it('should make prime operators into <mo> nodes', () => {
        expect(getMathML("f'")).toMatchSnapshot();
    });

    it('should generate <mphantom> nodes for \\phantom', () => {
        expect(getMathML("\\phantom{x}")).toMatchSnapshot();
    });

    it('should use <munderover> for large operators', () => {
        expect(getMathML("\\displaystyle\\sum_a^b")).toMatchSnapshot();
    });

    it('should use <msupsub> for integrals', () => {
        expect(getMathML("\\displaystyle\\int_a^b + " +
            "\\oiint_a^b + \\oiiint_a^b")).toMatchSnapshot();
    });

    it('should use <msupsub> for regular operators', () => {
        expect(getMathML("\\textstyle\\sum_a^b")).toMatchSnapshot();
    });
