Skip to content

Commit 978de58

Browse files
committed
Fix prettier issues (now that we are doing that in tests)
1 parent a5e8346 commit 978de58

File tree

11 files changed

+150
-82
lines changed

11 files changed

+150
-82
lines changed

testsuite/src/setupTex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { expect } from '@jest/globals';
2424
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
2525
// @ts-ignore
2626
import { source } from '#source/source.js';
27-
import {Locale} from '#js/util/Locale.js';
27+
import { Locale } from '#js/util/Locale.js';
2828

2929
declare const MathJax: any;
3030
type MATHITEM = MathItem<any, any, any>;

testsuite/src/source.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
declare module '#source/source.js' {
2-
export const source: {[name: string]: string};
2+
export const source: { [name: string]: string };
33
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ describe('Bbox', () => {
5252
});
5353

5454
it('Bbox-General-Error', () => {
55-
expectTexError('\\bbox[22-11=color]{a}')
56-
.toBe(`'22-11=color' doesn't look like a color, a padding dimension, or a style`);
55+
expectTexError('\\bbox[22-11=color]{a}').toBe(
56+
`'22-11=color' doesn't look like a color, a padding dimension, or a style`
57+
);
5758
});
5859
});
5960

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,4 +631,4 @@ describe('Nested Environments', () => {
631631

632632
/**********************************************************************************/
633633

634-
afterAll(() => getTokens('newcommand'));
634+
afterAll(() => getTokens('newcommand'));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ setupComponents({
1717
loader: {
1818
load: ['input/tex-base', '[tex]/require'],
1919
source: {
20-
'[tex]/error': '../testsuite/lib/error.js'
20+
'[tex]/error': '../testsuite/lib/error.js',
2121
},
2222
dependencies: {
2323
'[tex]/upgreek': ['input/tex-base', '[tex]/error'],

testsuite/tests/util/AsyncLoad.test.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,30 @@ describe('asyncLoad()', () => {
5454
package: {
5555
Package: {
5656
resolvePath: (file: string) => 'test:' + file,
57-
}
58-
}
59-
}
60-
}
57+
},
58+
},
59+
},
60+
},
6161
};
6262
expect(resolvePath('[x]/y.js', (file) => file)).toBe('test:[x]/y.js');
6363

6464
//
6565
// Remove MathJax._ and test relative and absolute paths
6666
//
67-
(global as any).MathJax = {}
68-
expect(resolvePath('./x.js', (file) => `rel:${file.substring(2)}`, (file) => `abs:${file}`)).toBe('rel:x.js');
69-
expect(resolvePath('x.js', (file) => `rel:${file.substring(2)}`, (file) => `abs:${file}`)).toBe('abs:x.js');
67+
(global as any).MathJax = {};
68+
expect(
69+
resolvePath(
70+
'./x.js',
71+
(file) => `rel:${file.substring(2)}`,
72+
(file) => `abs:${file}`
73+
)
74+
).toBe('rel:x.js');
75+
expect(
76+
resolvePath(
77+
'x.js',
78+
(file) => `rel:${file.substring(2)}`,
79+
(file) => `abs:${file}`
80+
)
81+
).toBe('abs:x.js');
7082
});
7183
});
Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
import { describe, test, expect } from '@jest/globals';
2-
import {Locale} from '#js/util/Locale.js';
2+
import { Locale } from '#js/util/Locale.js';
33
import '#js/util/asyncLoad/esm.js';
44

55
/**********************************************************************************/
66
/**********************************************************************************/
77

88
describe('Locale', () => {
9-
109
/********************************************************************************/
1110

1211
test('Set locale', async () => {
@@ -24,34 +23,50 @@ describe('Locale', () => {
2423
test('Register a component', async () => {
2524
const locale = Locale as any;
2625
Locale.registerLocaleFiles('component', '../testsuite/lib/component');
27-
expect(locale.locations.component).toEqual(['../testsuite/lib/component/locales', new Set()]);
26+
expect(locale.locations.component).toEqual([
27+
'../testsuite/lib/component/locales',
28+
new Set(),
29+
]);
2830
const error = console.error;
29-
console.error = (message) => {throw message};
30-
await expect(Locale.setLocale('de')).rejects
31-
.toMatch("MathJax(component): Can't load 'de.json': ENOENT: no such file or directory");
31+
console.error = (message) => {
32+
throw message;
33+
};
34+
await expect(Locale.setLocale('de')).rejects.toMatch(
35+
"MathJax(component): Can't load 'de.json': ENOENT: no such file or directory"
36+
);
3237
console.error = error;
3338
await Locale.setLocale('en');
34-
expect(locale.data.component).toEqual({en: {Id1: 'Test of %1 in %2'}});
35-
expect(Locale.message('component', 'Id1', 'message', 'Locale')).toBe('Test of message in Locale');
39+
expect(locale.data.component).toEqual({ en: { Id1: 'Test of %1 in %2' } });
40+
expect(Locale.message('component', 'Id1', 'message', 'Locale')).toBe(
41+
'Test of message in Locale'
42+
);
3643
});
3744

3845
/********************************************************************************/
3946

4047
test('Messages', async () => {
4148
Locale.registerLocaleFiles('component', '../testsuite/lib/component');
42-
await Locale.setLocale('en'); // load English backups
49+
await Locale.setLocale('en'); // load English backups
4350
await Locale.setLocale('test');
4451
expect(Locale.message('component', 'test1')).toBe('Has % percent');
4552
expect(Locale.message('component', 'test2', 'x')).toBe('Has x one');
46-
expect(Locale.message('component', 'test3', 'a', 'b')).toBe('Order b a reversed');
47-
expect(Locale.message('component', 'test4', 'a', 'b', 'c')).toBe('Skip a c');
53+
expect(Locale.message('component', 'test3', 'a', 'b')).toBe(
54+
'Order b a reversed'
55+
);
56+
expect(Locale.message('component', 'test4', 'a', 'b', 'c')).toBe(
57+
'Skip a c'
58+
);
4859
expect(Locale.message('component', 'test4')).toBe('Skip ');
49-
expect(Locale.message('component', 'test5', {hello: 'HELLO', world: 'WORLD'})).toBe('Named HELLO WORLD');
60+
expect(
61+
Locale.message('component', 'test5', { hello: 'HELLO', world: 'WORLD' })
62+
).toBe('Named HELLO WORLD');
5063
expect(Locale.message('component', 'Id1', 'a', 'b')).toBe('Test of a in b');
51-
expect(Locale.message('component', 'Id2'))
52-
.toBe("No localized or default version for message with id 'Id2' from 'component'");
53-
expect(Locale.message('undefined', 'Id1'))
54-
.toBe("No localized or default version for message with id 'Id1' from 'undefined'");
64+
expect(Locale.message('component', 'Id2')).toBe(
65+
"No localized or default version for message with id 'Id2' from 'component'"
66+
);
67+
expect(Locale.message('undefined', 'Id1')).toBe(
68+
"No localized or default version for message with id 'Id1' from 'undefined'"
69+
);
5570
expect(() => Locale.error('component', 'error', 'x')).toThrow('Error in x');
5671
});
5772

@@ -66,9 +81,7 @@ describe('Locale', () => {
6681
});
6782

6883
/********************************************************************************/
69-
7084
});
7185

72-
7386
/**********************************************************************************/
7487
/**********************************************************************************/

testsuite/tests/util/Styles.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ describe('CssStyles object', () => {
204204
'margin: 0;'
205205
);
206206
cssTest('margin:', {}, '');
207-
})
207+
});
208208

209209
test('border', () => {
210210
cssTest('border: 3px solid red', {

testsuite/tests/util/asyncLoad/esm.test.ts

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,57 @@ describe('asyncLoad() for esm', () => {
1111
test('asyncLoad()', async () => {
1212
const cjsFile = path.join('..', 'testsuite', 'lib', 'AsyncLoad.child.cjs');
1313
const mjsFile = path.join('..', 'testsuite', 'lib', 'AsyncLoad.child.mjs');
14-
const jsonFile = path.join('..', 'testsuite', 'lib', 'AsyncLoad.child.json');
15-
const relUnknown = path.join('..', 'testsuite', 'lib', 'AsyncLoad.unknown.cjs');
16-
const jsonUnknown = path.join('..', 'testsuite', 'lib', 'AsyncLoad.unknown.json');
14+
const jsonFile = path.join(
15+
'..',
16+
'testsuite',
17+
'lib',
18+
'AsyncLoad.child.json'
19+
);
20+
const relUnknown = path.join(
21+
'..',
22+
'testsuite',
23+
'lib',
24+
'AsyncLoad.unknown.cjs'
25+
);
26+
const jsonUnknown = path.join(
27+
'..',
28+
'testsuite',
29+
'lib',
30+
'AsyncLoad.unknown.json'
31+
);
1732
const absFile = path.join(root, cjsFile);
1833
const absJson = path.join(root, jsonFile);
1934
const absUnknown = path.join(root, relUnknown);
2035

21-
await expect(asyncLoad(cjsFile)).resolves.toEqual({loaded: true}); // relative file found
22-
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
23-
await expect(asyncLoad(absFile)).resolves.toEqual({loaded: true}); // absolute file found
24-
await expect(asyncLoad(absUnknown).catch(() => true)).resolves.toBe(true); // absolute file not found
36+
await expect(asyncLoad(cjsFile)).resolves.toEqual({ loaded: true }); // relative file found
37+
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
38+
await expect(asyncLoad(absFile)).resolves.toEqual({ loaded: true }); // absolute file found
39+
await expect(asyncLoad(absUnknown).catch(() => true)).resolves.toBe(true); // absolute file not found
2540

26-
await expect(asyncLoad(jsonFile)).resolves.toEqual({json: true}); // relative json file found
27-
await expect(asyncLoad(absJson)).resolves.toEqual({json: true}); // absolute json file found
28-
await expect(asyncLoad(jsonUnknown).catch(() => true)).resolves.toBe(true); // unknown file not found
41+
await expect(asyncLoad(jsonFile)).resolves.toEqual({ json: true }); // relative json file found
42+
await expect(asyncLoad(absJson)).resolves.toEqual({ json: true }); // absolute json file found
43+
await expect(asyncLoad(jsonUnknown).catch(() => true)).resolves.toBe(true); // unknown file not found
2944

30-
await expect(asyncLoad('#js/components/version.js') // load using package exports
31-
.then((result: any) => result.VERSION)).resolves.toBe(mathjax.version);
32-
await expect(asyncLoad('@mathjax/src/js/components/version.js') // load from module
33-
.then((result: any) => result.VERSION)).resolves.toBe(mathjax.version);
45+
await expect(
46+
asyncLoad('#js/components/version.js') // load using package exports
47+
.then((result: any) => result.VERSION)
48+
).resolves.toBe(mathjax.version);
49+
await expect(
50+
asyncLoad('@mathjax/src/js/components/version.js') // load from module
51+
.then((result: any) => result.VERSION)
52+
).resolves.toBe(mathjax.version);
3453

35-
await expect(asyncLoad(mjsFile).then((result: any) => result.loaded)).resolves.toBe(true); // mjs file loads
36-
expect(mathjax.asyncIsSynchronous).toBe(false); // esm.js is asynchronous
54+
await expect(
55+
asyncLoad(mjsFile).then((result: any) => result.loaded) // mjs file loads
56+
).resolves.toBe(true);
57+
expect(mathjax.asyncIsSynchronous).toBe(false); // esm.js is asynchronous
3758
});
3859

3960
test('setBaseURL() for esm', async () => {
4061
setBaseURL(lib);
4162
const relFile = './AsyncLoad.child.cjs';
4263
const relUnknown = './AsyncLoad.unknown.cjs';
43-
await expect(asyncLoad(relFile)).resolves.toEqual({ loaded: true }); // relative file found
44-
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
64+
await expect(asyncLoad(relFile)).resolves.toEqual({ loaded: true }); // relative file found
65+
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
4566
});
4667
});

testsuite/tests/util/asyncLoad/node.test.ts

Lines changed: 42 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,64 @@ describe('asyncLoad() for node', () => {
1313
test('asyncLoad()', async () => {
1414
const cjsFile = path.join('..', 'testsuite', 'lib', 'AsyncLoad.child.cjs');
1515
const mjsFile = path.join('..', 'testsuite', 'lib', 'AsyncLoad.child.mjs');
16-
const jsonFile = path.join('..', 'testsuite', 'lib', 'AsyncLoad.child.json');
17-
const relUnknown = path.join('..', 'testsuite', 'lib', 'AsyncLoad.unknown.cjs');
18-
const jsonUnknown = path.join('..', 'testsuite', 'lib', 'AsyncLoad.unknown.json');
16+
const jsonFile = path.join(
17+
'..',
18+
'testsuite',
19+
'lib',
20+
'AsyncLoad.child.json'
21+
);
22+
const relUnknown = path.join(
23+
'..',
24+
'testsuite',
25+
'lib',
26+
'AsyncLoad.unknown.cjs'
27+
);
28+
const jsonUnknown = path.join(
29+
'..',
30+
'testsuite',
31+
'lib',
32+
'AsyncLoad.unknown.json'
33+
);
1934
const absFile = path.join(root, cjsFile);
2035
const absJson = path.join(root, jsonFile);
2136
const absUnknown = path.join(root, relUnknown);
2237

23-
await expect(asyncLoad(cjsFile)).resolves.toEqual({loaded: true}); // relative file found
24-
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
25-
await expect(asyncLoad(absFile)).resolves.toEqual({loaded: true}); // absolute file found
26-
await expect(asyncLoad(absUnknown).catch(() => true)).resolves.toBe(true); // absolute file not found
38+
await expect(asyncLoad(cjsFile)).resolves.toEqual({ loaded: true }); // relative file found
39+
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
40+
await expect(asyncLoad(absFile)).resolves.toEqual({ loaded: true }); // absolute file found
41+
await expect(asyncLoad(absUnknown).catch(() => true)).resolves.toBe(true); // absolute file not found
2742

28-
await expect(asyncLoad(jsonFile)).resolves.toEqual({json: true}); // relative json file found
29-
await expect(asyncLoad(absJson)).resolves.toEqual({json: true}); // absolute json file found
30-
await expect(asyncLoad(jsonUnknown).catch(() => true)).resolves.toBe(true); // unknown file not found
43+
await expect(asyncLoad(jsonFile)).resolves.toEqual({ json: true }); // relative json file found
44+
await expect(asyncLoad(absJson)).resolves.toEqual({ json: true }); // absolute json file found
45+
await expect(asyncLoad(jsonUnknown).catch(() => true)).resolves.toBe(true); // unknown file not found
3146

32-
await expect(asyncLoad('#js/../cjs/components/version.js') // load using package exports
33-
.then((result: any) => result.VERSION)).resolves.toBe(mathjax.version);
34-
await expect(asyncLoad('@mathjax/src/js/components/version.js') // load from module
35-
.then((result: any) => result.VERSION)).resolves.toBe(mathjax.version);
47+
await expect(
48+
asyncLoad('#js/../cjs/components/version.js') // load using package exports
49+
.then((result: any) => result.VERSION)
50+
).resolves.toBe(mathjax.version);
51+
await expect(
52+
asyncLoad('@mathjax/src/js/components/version.js') // load from module
53+
.then((result: any) => result.VERSION)
54+
).resolves.toBe(mathjax.version);
3655

37-
await expect(asyncLoad(mjsFile).catch(() => true)).resolves.toBe(true); // mjs file fails
38-
expect(mathjax.asyncIsSynchronous).toBe(true); // node.js is synchronous
56+
await expect(asyncLoad(mjsFile).catch(() => true)).resolves.toBe(true); // mjs file fails
57+
expect(mathjax.asyncIsSynchronous).toBe(true); // node.js is synchronous
3958

4059
//
4160
// Test mathjax.json separately, as asyncLoad doesn't call it.
4261
//
43-
await expect(mathjax.json(jsonFile)).resolves.toEqual({json: true});
44-
await expect(mathjax.json(absJson)).resolves.toEqual({json: true});
45-
await expect(mathjax.json(jsonUnknown).catch(() => true)).resolves.toBe(true);
62+
await expect(mathjax.json(jsonFile)).resolves.toEqual({ json: true });
63+
await expect(mathjax.json(absJson)).resolves.toEqual({ json: true });
64+
await expect(mathjax.json(jsonUnknown).catch(() => true)).resolves.toBe(
65+
true
66+
);
4667
});
4768

4869
test('setBaseURL() for node', async () => {
4970
setBaseURL(lib);
5071
const relFile = './AsyncLoad.child.cjs';
5172
const relUnknown = './AsyncLoad.unknown.cjs';
52-
await expect(asyncLoad(relFile)).resolves.toEqual({ loaded: true }); // relative file found
53-
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
73+
await expect(asyncLoad(relFile)).resolves.toEqual({ loaded: true }); // relative file found
74+
await expect(asyncLoad(relUnknown).catch(() => true)).resolves.toBe(true); // relative file not found
5475
});
5576
});

0 commit comments

Comments
 (0)