@@ -98,7 +98,7 @@ const Samples: Record<Expression, string> = {
9898 '<mn>2</mn>' +
9999 '</msup>' +
100100 '</math>' ,
101- [ Expression . Maction ] :
101+ [ Expression . Maction ] :
102102 '<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">' +
103103 '<maction actiontype="toggle" selection="2" data-collapsible="true" id="mjx-collapse-0">' +
104104 '<mtext>◂f()▸</mtext>' +
@@ -258,6 +258,13 @@ export class ApiFileTest extends ApiTest {
258258 ) {
259259 const sample = this . getSample ( input ) ;
260260 await System . setupEngine ( feature || ApiTest . SETUP ) ;
261+ await this . asyncTest ( func , sample , result ) ;
262+ await this . syncTest ( func , sample , result ) ;
263+ System . setupEngine ( { mode : 'async' } ) ;
264+ }
265+
266+ private async asyncTest ( func : string , sample : string , result : string ) {
267+ System . setupEngine ( { mode : 'async' } ) ;
261268 SystemExternal . fs . promises . readFile = jest . fn ( ( _file : string ) => {
262269 return Promise . resolve ( sample ) ;
263270 } ) ;
@@ -268,6 +275,14 @@ export class ApiFileTest extends ApiTest {
268275 this . assert . equal ( output . toString ( ) , result ) ;
269276 }
270277
278+ private async syncTest ( func : string , sample : string , result : string ) {
279+ System . setupEngine ( { mode : 'sync' } ) ;
280+ SystemExternal . fs . readFileSync = jest . fn ( ( _file : string ) => sample ) ;
281+ SystemExternal . fs . writeFileSync = jest . fn ( ) ;
282+ let output = ( System . file as any ) [ func ] ( 'input' , 'output' ) ;
283+ this . assert . equal ( output , result ) ;
284+ }
285+
271286 /**
272287 * @override
273288 */
@@ -278,6 +293,14 @@ export class ApiFileTest extends ApiTest {
278293 return super . setUpTest ( ) ;
279294 }
280295
296+ /**
297+ * @override
298+ */
299+ public async tearDownTest ( ) : Promise < string > {
300+ jest . resetAllMocks ( ) ;
301+ return super . tearDownTest ( ) ;
302+ }
303+
281304}
282305
283306export class WorkerTest extends ApiTest {
@@ -335,7 +358,7 @@ export class DebugTest extends ApiTest {
335358 public information = 'Debugger test.' ;
336359
337360 private oldDebug : boolean | string = null ;
338-
361+
339362 constructor ( ) {
340363 super ( ) ;
341364 this . pickFields . push ( 'strings' ) ;
@@ -356,12 +379,12 @@ export class DebugTest extends ApiTest {
356379 * @override
357380 */
358381 public async tearDownTest ( ) : Promise < string > {
382+ Debugger . getInstance ( ) . exit ( ) ;
359383 if ( this . oldDebug === null ) {
360384 delete ApiTest . SETUP [ 'debug' ] ;
361385 } else {
362386 ApiTest . SETUP [ 'debug' ] = this . oldDebug ;
363387 }
364- jest . clearAllMocks ( ) ;
365388 return super . tearDownTest ( ) ;
366389 }
367390
@@ -430,8 +453,8 @@ export class DebugFileTest extends DebugTest {
430453 * @override
431454 */
432455 public async tearDownTest ( ) : Promise < string > {
433- // TODO: change this to exit.
434- ( Debugger . getInstance ( ) as any ) . stream_ = null ;
456+ jest . resetAllMocks ( ) ;
435457 return super . tearDownTest ( ) ;
436458 }
459+
437460}
0 commit comments