test: implemented latex partial function representation

This commit is contained in:
Alexandre Nunes 2020-09-19 16:44:45 -03:00
parent e0004dab9a
commit f8a3a8d9b5

@ -513,6 +513,77 @@ describe('#convert', () => {
});
});
});
describe('given math string with partial function', () => {
test('returns latex partial function representation', () => {
const mathml = `
<root>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mi>f</mi>
<mfenced separators="|">
<mrow>
<mi>x</mi>
</mrow>
</mfenced>
<mo>=</mo>
<mfenced open="{" close="" separators="|">
<mrow>
<mtable>
<mtr>
<mtd>
<mrow>
<maligngroup></maligngroup>
<msup>
<mrow>
<mi>x</mi>
</mrow>
<mrow>
<mn>2</mn>
</mrow>
</msup>
<mo>,</mo>
<mi>x</mi>
<mo>&lt;</mo>
<mn>0</mn>
</mrow>
</mtd>
</mtr>
<mtr>
<mtd>
<mrow>
<maligngroup></maligngroup>
<msup>
<mrow>
<mi>e</mi>
</mrow>
<mrow>
<mi>x</mi>
</mrow>
</msup>
<mo>,</mo>
<mi>x</mi>
<mo></mo>
<mn>0</mn>
</mrow>
</mtd>
</mtr>
</mtable>
</mrow>
</mfenced>
</math>
</root>
`;
const result = MathMLToLaTeX.convert(mathml);
expect(result).toBe(
`f\\left(x\\right)=\\left{\\begin{matrix}\n x^{2} , x < 0 \\\\ e^{x} , x \\geq 0 \n\\end{matrix}\\right`.replace(
/\n/g,
'',
),
);
});
});
});
});