forked from plotly/plotly.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmathjax_config_test.js
88 lines (75 loc) · 2.73 KB
/
mathjax_config_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* eslint-disable new-cap */
var Plotly = require('../../../lib/index');
var delay = require('../assets/delay');
var createGraphDiv = require('../assets/create_graph_div');
var destroyGraphDiv = require('../assets/destroy_graph_div');
var loadScript = require('../assets/load_script');
// eslint-disable-next-line no-undef
var mathjaxVersion = __karma__.config.mathjaxVersion;
describe('Test MathJax v' + mathjaxVersion + ' config test:', function() {
var gd;
beforeAll(function(done) {
gd = createGraphDiv();
if(mathjaxVersion === 3) {
window.MathJax = {
startup: {
output: 'chtml',
tex: {
inlineMath: [['|', '|']]
}
}
};
}
var src = mathjaxVersion === 3 ?
'/base/node_modules/mathjax-v3/es5/tex-svg.js' :
'/base/node_modules/mathjax-v2/MathJax.js?config=TeX-AMS_SVG';
loadScript(src, done);
});
afterAll(destroyGraphDiv);
it('should maintain startup renderer & inlineMath after SVG rendering', function(done) {
if(mathjaxVersion === 2) {
window.MathJax.Hub.Config({
tex2jax: {
inlineMath: [['|', '|']]
}
});
window.MathJax.Hub.setRenderer('CHTML');
}
// before plot
if(mathjaxVersion === 3) {
expect(window.MathJax.config.startup.output).toEqual('chtml');
expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]);
}
if(mathjaxVersion === 2) {
expect(window.MathJax.Hub.config.menuSettings.renderer).toEqual('');
expect(window.MathJax.Hub.config.tex2jax.inlineMath).toEqual([['|', '|']]);
}
Plotly.newPlot(gd, {
data: [{
y: [1, 2]
}],
layout: {
title: {
text: '$E=mc^2$'
}
}
})
.then(function() {
// after plot
if(mathjaxVersion === 3) {
expect(window.MathJax.config.startup.output).toEqual('chtml');
expect(window.MathJax.config.startup.tex.inlineMath).toEqual([['|', '|']]);
}
if(mathjaxVersion === 2) {
expect(window.MathJax.Hub.config.menuSettings.renderer).toEqual('');
}
})
.then(delay(1000)) // TODO: why we need this delay for mathjax v2 here?
.then(function() {
if(mathjaxVersion === 2) {
expect(window.MathJax.Hub.config.tex2jax.inlineMath).toEqual([['|', '|']]);
}
})
.then(done, done.fail);
});
});