diff --git a/__test__/index.test.ts b/__test__/index.test.ts index 3fc5cc9..35ba139 100755 --- a/__test__/index.test.ts +++ b/__test__/index.test.ts @@ -1207,4 +1207,98 @@ describe('#convert', () => { }); }); }); + + describe('given math string with msub tag', () => { + describe('msub tag contains single char contents', () => { + test('convert msub joining its two char contents with _ and wrap subscript in brackets', () => { + const mathml = ` + + + + x + 2 + + + + `; + + const result = MathMLToLaTeX.convert(mathml); + + expect(result).toMatch('x_{2}'); + }); + }); + + describe('msub tag contains base with single char content and subscript with more than one char content', () => { + test('convert msub joining its two char contents with _ and wrap exponent in brackets', () => { + const mathml = ` + + + + x + + a + + + b + + + + + `; + + const result = MathMLToLaTeX.convert(mathml); + + expect(result).toMatch('x_{a + b}'); + }); + }); + + describe('msub tag contains subscript with single char content and base with more than one char content', () => { + test('convert msub joining its multi char contents with _ and wrap base in parenthesis', () => { + const mathml = ` + + + + + x + + + y + + 2 + + + + `; + + const result = MathMLToLaTeX.convert(mathml); + + expect(result).toMatch('\\left(x + y\\right)_{2}'); + }); + }); + + describe('msub tag contains both base and subscript with more than one char content', () => { + test('convert msub joining its multi char contents with _, wrap base in parenthesis and subscript in brackets', () => { + const mathml = ` + + + + + x + + + y + + + 2 + + + 2 + + + + + `; + + const result = MathMLToLaTeX.convert(mathml); + + expect(result).toMatch('\\left(x + y\\right)_{2 + 2}'); + }); + }); + }); });