From 720dde60e375698ceb672a21d40457ace850b117 Mon Sep 17 00:00:00 2001 From: Alexandre Nunes Date: Tue, 15 Sep 2020 12:22:33 -0300 Subject: [PATCH] test: implement msub tag use case --- __test__/index.test.ts | 94 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) 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}'); + }); + }); + }); });