Skip to content

Commit 0a0f8e5

Browse files
committed
Update tests to improve coverage of some modules
1 parent 27c47f3 commit 0a0f8e5

File tree

3 files changed

+99
-3
lines changed

3 files changed

+99
-3
lines changed

testsuite/tests/input/tex/Bbm.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { afterAll, beforeEach, describe, test } from '@jest/globals';
2-
import { getTokens, toXmlMatch, setupTex, tex2mml } from '#helpers';
1+
import { afterAll, beforeEach, describe, test, expect } from '@jest/globals';
2+
import { getTokens, toXmlMatch, setupTex, setupComponents, tex2mml } from '#helpers';
33
import '#js/input/tex/bbm/BbmConfiguration';
44

55
/**********************************************************************************/
@@ -153,4 +153,18 @@ describe('Bbm', () => {
153153
/**********************************************************************************/
154154
/**********************************************************************************/
155155

156+
declare const MathJax: any;
157+
158+
setupComponents({loader: {load: ['input/tex-base', 'output/chtml']}});
159+
160+
describe('Bbm', () => {
161+
162+
test('bbm with no output', async() => {
163+
await expect(MathJax.loader.load('[tex]/bbm').then(() => true)).resolves.toBe(true);
164+
});
165+
});
166+
167+
/**********************************************************************************/
168+
/**********************************************************************************/
169+
156170
afterAll(() => getTokens('bbm'));

testsuite/tests/input/tex/TagFormat.test.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,88 @@ describe('Tagformat', () => {
172172

173173
/********************************************************************************/
174174

175+
test('Array tag', () => {
176+
setupTex(['base', 'ams', 'tagformat'], {
177+
tagformat: {
178+
tag: (tag: string) => ['|', tag, '|'],
179+
},
180+
tags: 'ams'
181+
});
182+
toXmlMatch(
183+
tex2mml('x \\tag{1}'),
184+
`<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="x \\tag{1}" display="block">
185+
<mtable displaystyle="true" data-latex="x \\tag{1}">
186+
<mlabeledtr>
187+
<mtd id="mjx-eqn:1">
188+
<mtext data-latex="\\text{|}">|</mtext>
189+
<mtext data-latex="\\text{1}">1</mtext>
190+
<mtext data-latex="\\text{|}">|</mtext>
191+
</mtd>
192+
<mtd>
193+
<mi data-latex="\\tag{1}">x</mi>
194+
</mtd>
195+
</mlabeledtr>
196+
</mtable>
197+
</math>`
198+
);
199+
});
200+
201+
/********************************************************************************/
202+
203+
test('Array tag with empty entry', () => {
204+
setupTex(['base', 'ams', 'tagformat'], {
205+
tagformat: {
206+
tag: (tag: string) => ['', tag, '.'],
207+
},
208+
tags: 'ams'
209+
});
210+
toXmlMatch(
211+
tex2mml('x \\tag{1}'),
212+
`<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="x \\tag{1}" display="block">
213+
<mtable displaystyle="true" data-latex="x \\tag{1}">
214+
<mlabeledtr>
215+
<mtd id="mjx-eqn:1">
216+
<mtext data-latex="\\text{1}">1</mtext>
217+
<mtext data-latex="\\text{.}">.</mtext>
218+
</mtd>
219+
<mtd>
220+
<mi data-latex="\\tag{1}">x</mi>
221+
</mtd>
222+
</mlabeledtr>
223+
</mtable>
224+
</math>`
225+
);
226+
});
227+
228+
/********************************************************************************/
229+
230+
test('Array tag with null entry', () => {
231+
setupTex(['base', 'ams', 'tagformat'], {
232+
tagformat: {
233+
tag: (tag: string) => [ , tag, '.'],
234+
},
235+
tags: 'ams'
236+
});
237+
toXmlMatch(
238+
tex2mml('x \\tag{1}'),
239+
`<math xmlns="http://www.w3.org/1998/Math/MathML" data-latex="x \\tag{1}" display="block">
240+
<mtable displaystyle="true" data-latex="x \\tag{1}">
241+
<mlabeledtr>
242+
<mtd id="mjx-eqn:1">
243+
<mtext data-latex="\\text{1}">1</mtext>
244+
<mtext data-latex="\\text{.}">.</mtext>
245+
</mtd>
246+
<mtd>
247+
<mi data-latex="\\tag{1}">x</mi>
248+
</mtd>
249+
</mlabeledtr>
250+
</mtable>
251+
</math>`
252+
);
253+
});
254+
255+
/********************************************************************************/
256+
175257
});
176258

177259
/**********************************************************************************/

ts/input/tex/base/BaseItems.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ export class FnItem extends BaseItem {
790790
// @test Mathop Apply, Mathop No Apply
791791
if (
792792
top.isKind('TeXAtom') &&
793-
top.childNodes[0]?.childNodes?.length === 0
793+
top.childNodes[0].childNodes.length === 0
794794
) {
795795
return [[top, item], true];
796796
}

0 commit comments

Comments
 (0)