Skip to content

Commit 89b24bd

Browse files
committed
update jasmine tests for mathjax v3/v4
1 parent 1ae7aad commit 89b24bd

3 files changed

Lines changed: 23 additions & 49 deletions

File tree

‎test/jasmine/bundle_tests/mathjax_config_test.js‎

Lines changed: 13 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -16,46 +16,28 @@ describe('Test MathJax v' + mathjaxVersion + ' config test:', function() {
1616
beforeAll(function(done) {
1717
gd = createGraphDiv();
1818

19-
if(mathjaxVersion === 3) {
20-
window.MathJax = {
21-
startup: {
22-
output: 'chtml',
23-
tex: {
24-
inlineMath: [['|', '|']]
25-
}
19+
window.MathJax = {
20+
startup: {
21+
output: 'chtml',
22+
tex: {
23+
inlineMath: [['|', '|']]
2624
}
27-
};
28-
}
25+
}
26+
};
2927

30-
var src = mathjaxVersion === 3 ?
28+
const src = mathjaxVersion === 3 ?
3129
'/base/node_modules/@plotly/mathjax-v3/es5/tex-svg.js' :
32-
'/base/node_modules/@plotly/mathjax-v2/MathJax.js?config=TeX-AMS_SVG';
30+
'/base/node_modules/@plotly/mathjax-v4/tex-svg.js';
3331

3432
loadScript(src, done);
3533
});
3634

3735
afterAll(destroyGraphDiv);
3836

3937
it('should maintain startup renderer & inlineMath after SVG rendering', function(done) {
40-
if(mathjaxVersion === 2) {
41-
window.MathJax.Hub.Config({
42-
tex2jax: {
43-
inlineMath: [['|', '|']]
44-
}
45-
});
46-
47-
window.MathJax.Hub.setRenderer('CHTML');
48-
}
49-
5038
// before plot
51-
if(mathjaxVersion === 3) {
52-
expect(window.MathJax.config.startup.output).toEqual('chtml');
53-
expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]);
54-
}
55-
if(mathjaxVersion === 2) {
56-
expect(window.MathJax.Hub.config.menuSettings.renderer).toEqual('');
57-
expect(window.MathJax.Hub.config.tex2jax.inlineMath).toEqual([['|', '|']]);
58-
}
39+
expect(window.MathJax.config.startup.output).toEqual('chtml');
40+
expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]);
5941

6042
Plotly.newPlot(gd, {
6143
data: [{
@@ -69,19 +51,8 @@ describe('Test MathJax v' + mathjaxVersion + ' config test:', function() {
6951
})
7052
.then(function() {
7153
// after plot
72-
if(mathjaxVersion === 3) {
73-
expect(window.MathJax.config.startup.output).toEqual('chtml');
74-
expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]);
75-
}
76-
if(mathjaxVersion === 2) {
77-
expect(window.MathJax.Hub.config.menuSettings.renderer).toEqual('');
78-
}
79-
})
80-
.then(delay(1000)) // TODO: why we need this delay for mathjax v2 here?
81-
.then(function() {
82-
if(mathjaxVersion === 2) {
83-
expect(window.MathJax.Hub.config.tex2jax.inlineMath).toEqual([['|', '|']]);
84-
}
54+
expect(window.MathJax.config.startup.output).toEqual('chtml');
55+
expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]);
8556
})
8657
.then(done, done.fail);
8758
});

‎test/jasmine/bundle_tests/mathjax_test.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ var mathjaxVersion = __karma__.config.mathjaxVersion;
1010

1111
describe('Test MathJax v' + mathjaxVersion + ':', function() {
1212
beforeAll(function(done) {
13-
var src = mathjaxVersion === 3 ?
13+
const src = mathjaxVersion === 3 ?
1414
'/base/node_modules/@plotly/mathjax-v3/es5/tex-svg.js' :
15-
'/base/node_modules/@plotly/mathjax-v2/MathJax.js?config=TeX-AMS-MML_SVG';
15+
'/base/node_modules/@plotly/mathjax-v4/tex-svg.js';
1616

17+
// TODO: `?config=` is not needed for MathJax v3 and onward,
18+
// should we adjust these tests?
19+
1720
// N.B. we have to load MathJax "dynamically" as Karma
1821
// does not undefined the MathJax's `?config=` parameter.
1922
//

‎test/jasmine/karma.conf.js‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if (argv.info) {
6969
'',
7070
'Other options:',
7171
' - `--info`: show this info message',
72-
' - `--mathjax3`: to load mathjax v3 in relevant test',
72+
' - `--mathjax3`: to load mathjax v3 in relevant test (otherwise mathjax v4 is loaded)',
7373
' - `--Chrome` (alias `--chrome`): run test in (our custom) Chrome browser',
7474
' - `--Firefox` (alias `--FF`, `--firefox`): run test in (our custom) Firefox browser',
7575
' - `--nowatch (dflt: `false`, `true` on CI)`: run karma w/o `autoWatch` / multiple run mode',
@@ -128,8 +128,8 @@ if (isFullSuite) {
128128

129129
var pathToCustomMatchers = path.join(__dirname, 'assets', 'custom_matchers.js');
130130
var pathToTopojsonDist = path.join(__dirname, '..', '..', 'topojson', 'dist');
131-
var pathToMathJax2 = path.join(__dirname, '..', '..', 'node_modules', '@plotly/mathjax-v2');
132131
var pathToMathJax3 = path.join(__dirname, '..', '..', 'node_modules', '@plotly/mathjax-v3');
132+
var pathToMathJax4 = path.join(__dirname, '..', '..', 'node_modules', '@plotly/mathjax-v4');
133133
var pathToVirtualWebgl = path.join(__dirname, '..', '..', 'node_modules', 'virtual-webgl', 'src', 'virtual-webgl.js');
134134

135135
var reporters = [];
@@ -200,10 +200,10 @@ func.defaultConfig = {
200200
// N.B. the rest of this field is filled below
201201
files: [
202202
pathToCustomMatchers,
203-
// available to fetch from /base/node_modules/@plotly/mathjax-v2/
203+
// available to fetch from /base/node_modules/@plotly/mathjax-v3/
204204
// more info: http://karma-runner.github.io/3.0/config/files.html
205-
{ pattern: pathToMathJax2 + '/**', included: false, watched: false, served: true },
206205
{ pattern: pathToMathJax3 + '/**', included: false, watched: false, served: true },
206+
{ pattern: pathToMathJax4 + '/**', included: false, watched: false, served: true },
207207
{ pattern: pathToTopojsonDist + '/**', included: false, watched: false, served: true }
208208
],
209209

@@ -308,7 +308,7 @@ func.defaultConfig = {
308308
tagPrefix: '@',
309309
skipTags: isCI ? 'noCI' : null,
310310

311-
mathjaxVersion: argv.mathjax3 ? 3 : 2,
311+
mathjaxVersion: argv.mathjax3 ? 3 : 4,
312312

313313
// See https://jasmine.github.io/api/3.4/Configuration.html
314314
jasmine: {

0 commit comments

Comments
 (0)