diff --git a/testsuite/src/xmlMatch.ts b/testsuite/src/xmlMatch.ts index 6d2e794d2..1ef3421f6 100644 --- a/testsuite/src/xmlMatch.ts +++ b/testsuite/src/xmlMatch.ts @@ -24,7 +24,7 @@ expect.extend({ * @param {string} received The string received from the tests * @param {string} expected The string expected to be produced by the tests */ -export function toXmlMatch(received: string, expected: string) { +function toXmlMatch(received: string, expected: string) { // This is slightly awkward way of getting around ts-jest problems with custom // matcher extensions. (expect(received) as any).toBeXmlMatch(expected); diff --git a/testsuite/tests/input/tex/ConfigMacros.test.ts b/testsuite/tests/input/tex/ConfigMacros.test.ts index 2f00538d1..d8debda68 100644 --- a/testsuite/tests/input/tex/ConfigMacros.test.ts +++ b/testsuite/tests/input/tex/ConfigMacros.test.ts @@ -1,17 +1,16 @@ -import { beforeEach, describe, it } from '@jest/globals'; -import { toXmlMatch, setupTex, tex2mml } from '#helpers'; +import { beforeEach, describe, expect, it } from '@jest/globals'; +import { setupTex, tex2mml } from '#helpers'; import '#js/input/tex/configmacros/ConfigMacrosConfiguration'; beforeEach(() => {}); function runMacroTests( macros: {[key: string]: any}, - expected: string, control: string, macro: string) { setupTex(['base', 'configmacros'], macros); - toXmlMatch(tex2mml(control), expected.replace('PH', control)); - toXmlMatch(tex2mml(macro), expected.replace('PH', macro)); + expect(tex2mml(control)).toMatchSnapshot(); + expect(tex2mml(macro)).toMatchSnapshot(); } /**********************************************************************************/ @@ -22,16 +21,7 @@ describe('Config Macros Active', () => { /********************************************************************************/ it('Macros Simple', () => { - runMacroTests( - {active: {"@": "~"}}, - ` - A -   - a - `, - 'A~a', - 'A@a' - ); + runMacroTests({active: {"@": "~"}}, 'A~a', 'A@a'); }); /********************************************************************************/ @@ -46,16 +36,7 @@ describe('Config Macros Commands', () => { /********************************************************************************/ it('Commands Simple', () => { - runMacroTests( - {macros: {"RR": "{\\bf R}"}}, - ` - - R - - `, - '{\\bf R}', - '\\RR' - ); + runMacroTests({macros: {"RR": "{\\bf R}"}}, '{\\bf R}', '\\RR'); }); /********************************************************************************/ @@ -63,14 +44,6 @@ describe('Config Macros Commands', () => { it('Commands Argument', () => { runMacroTests( {macros: {"bold": ["{\\bf #1}", 1]}}, - ` - - b - o - l - d - - `, '{\\bf bold}', '\\bold{bold}' ); @@ -81,21 +54,6 @@ describe('Config Macros Commands', () => { it('Commands Aux Argument', () => { runMacroTests( {macros: {"foo": ["\\mbox{first } #1 \\mbox{ second } #2", 2, ["[", "]"]]}}, - ` - - first  - - h - i - -  second  - - t - h - e - r - e - `, '\\mbox{first } hi \\mbox{ second } there', '\\foo[hi]{there}' ); @@ -115,11 +73,6 @@ describe('Config Macros Environment', () => { it('Environment Simple', () => { runMacroTests( {environments: {"myHeartEnv": ["\\heartsuit", "\\spadesuit"]}}, - ` - - a - - `, '\\begin{myHeartEnv}a\\end{myHeartEnv}', '\\begin{myHeartEnv}a\\end{myHeartEnv}' ); diff --git a/testsuite/tests/input/tex/__snapshots__/ConfigMacros.test.ts.snap b/testsuite/tests/input/tex/__snapshots__/ConfigMacros.test.ts.snap new file mode 100644 index 000000000..2520af291 --- /dev/null +++ b/testsuite/tests/input/tex/__snapshots__/ConfigMacros.test.ts.snap @@ -0,0 +1,107 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Config Macros Active Macros Simple 1`] = ` +" + A +   + a +" +`; + +exports[`Config Macros Active Macros Simple 2`] = ` +" + A +   + a +" +`; + +exports[`Config Macros Commands Commands Argument 1`] = ` +" + + b + o + l + d + +" +`; + +exports[`Config Macros Commands Commands Argument 2`] = ` +" + + b + o + l + d + +" +`; + +exports[`Config Macros Commands Commands Aux Argument 1`] = ` +" + + first  + + h + i + +  second  + + t + h + e + r + e +" +`; + +exports[`Config Macros Commands Commands Aux Argument 2`] = ` +" + + first  + + h + i + +  second  + + t + h + e + r + e +" +`; + +exports[`Config Macros Commands Commands Simple 1`] = ` +" + + R + +" +`; + +exports[`Config Macros Commands Commands Simple 2`] = ` +" + + R + +" +`; + +exports[`Config Macros Environment Environment Simple 1`] = ` +" + + a + +" +`; + +exports[`Config Macros Environment Environment Simple 2`] = ` +" + + a + +" +`;