1- import { beforeEach , describe , it } from '@jest/globals' ;
2- import { toXmlMatch , setupTex , tex2mml } from '#helpers' ;
1+ import { beforeEach , describe , expect , it } from '@jest/globals' ;
2+ import { setupTex , tex2mml } from '#helpers' ;
33import '#js/input/tex/configmacros/ConfigMacrosConfiguration' ;
44
55beforeEach ( ( ) => { } ) ;
66
77function runMacroTests (
88 macros : { [ key : string ] : any } ,
9- expected : string ,
109 control : string ,
1110 macro : string ) {
1211 setupTex ( [ 'base' , 'configmacros' ] , macros ) ;
13- toXmlMatch ( tex2mml ( control ) , expected . replace ( 'PH' , control ) ) ;
14- toXmlMatch ( tex2mml ( macro ) , expected . replace ( 'PH' , macro ) ) ;
12+ expect ( tex2mml ( control ) ) . toMatchSnapshot ( ) ;
13+ expect ( tex2mml ( macro ) ) . toMatchSnapshot ( ) ;
1514}
1615
1716/**********************************************************************************/
@@ -22,16 +21,7 @@ describe('Config Macros Active', () => {
2221 /********************************************************************************/
2322
2423 it ( 'Macros Simple' , ( ) => {
25- runMacroTests (
26- { active : { "@" : "~" } } ,
27- `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="PH" display="block">
28- <mi data-latex="A">A</mi>
29- <mtext data-latex="~"> </mtext>
30- <mi data-latex="a">a</mi>
31- </math>` ,
32- 'A~a' ,
33- 'A@a'
34- ) ;
24+ runMacroTests ( { active : { "@" : "~" } } , 'A~a' , 'A@a' ) ;
3525 } ) ;
3626
3727 /********************************************************************************/
@@ -46,31 +36,14 @@ describe('Config Macros Commands', () => {
4636 /********************************************************************************/
4737
4838 it ( 'Commands Simple' , ( ) => {
49- runMacroTests (
50- { macros : { "RR" : "{\\bf R}" } } ,
51- `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="PH" display="block">
52- <mrow data-mjx-texclass="ORD" data-latex="{\\bf R}">
53- <mi mathvariant="bold" data-latex="R">R</mi>
54- </mrow>
55- </math>` ,
56- '{\\bf R}' ,
57- '\\RR'
58- ) ;
39+ runMacroTests ( { macros : { "RR" : "{\\bf R}" } } , '{\\bf R}' , '\\RR' ) ;
5940 } ) ;
6041
6142 /********************************************************************************/
6243
6344 it ( 'Commands Argument' , ( ) => {
6445 runMacroTests (
6546 { macros : { "bold" : [ "{\\bf #1}" , 1 ] } } ,
66- `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="PH" display="block">
67- <mrow data-mjx-texclass="ORD" data-latex="{\\bf bold}">
68- <mi mathvariant="bold" data-latex="b">b</mi>
69- <mi mathvariant="bold" data-latex="o">o</mi>
70- <mi mathvariant="bold" data-latex="l">l</mi>
71- <mi mathvariant="bold" data-latex="d">d</mi>
72- </mrow>
73- </math>` ,
7447 '{\\bf bold}' ,
7548 '\\bold{bold}'
7649 ) ;
@@ -81,21 +54,6 @@ describe('Config Macros Commands', () => {
8154 it ( 'Commands Aux Argument' , ( ) => {
8255 runMacroTests (
8356 { macros : { "foo" : [ "\\mbox{first } #1 \\mbox{ second } #2" , 2 , [ "[" , "]" ] ] } } ,
84- `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="PH" display="block">
85- <mstyle displaystyle="false" data-latex="\\mbox{first }">
86- <mtext>first </mtext>
87- </mstyle>
88- <mi data-latex="h">h</mi>
89- <mi data-latex="i">i</mi>
90- <mstyle displaystyle="false" data-latex="\\mbox{ second }">
91- <mtext> second </mtext>
92- </mstyle>
93- <mi data-latex="t">t</mi>
94- <mi data-latex="h">h</mi>
95- <mi data-latex="e">e</mi>
96- <mi data-latex="r">r</mi>
97- <mi data-latex="e">e</mi>
98- </math>` ,
9957 '\\mbox{first } hi \\mbox{ second } there' ,
10058 '\\foo[hi]{there}'
10159 ) ;
@@ -115,11 +73,6 @@ describe('Config Macros Environment', () => {
11573 it ( 'Environment Simple' , ( ) => {
11674 runMacroTests (
11775 { environments : { "myHeartEnv" : [ "\\heartsuit" , "\\spadesuit" ] } } ,
118- `<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="\\begin{myHeartEnv}a\\end{myHeartEnv}" display="block">
119- <mi mathvariant="normal" data-latex="\\heartsuit">♡</mi>
120- <mi data-latex="a">a</mi>
121- <mi mathvariant="normal" data-latex="\\spadesuit">♠</mi>
122- </math>` ,
12376 '\\begin{myHeartEnv}a\\end{myHeartEnv}' ,
12477 '\\begin{myHeartEnv}a\\end{myHeartEnv}'
12578 ) ;
0 commit comments