|
| 1 | +/* eslint-disable new-cap */ |
| 2 | + |
| 3 | +var Plotly = require('@lib/index'); |
| 4 | + |
| 5 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 6 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
| 7 | +var loadScript = require('../assets/load_script'); |
| 8 | + |
| 9 | +// eslint-disable-next-line no-undef |
| 10 | +var mathjaxVersion = __karma__.config.mathjaxVersion; |
| 11 | + |
| 12 | +describe('Test MathJax v' + mathjaxVersion + ' config test:', function() { |
| 13 | + var gd; |
| 14 | + |
| 15 | + beforeAll(function(done) { |
| 16 | + gd = createGraphDiv(); |
| 17 | + |
| 18 | + if(mathjaxVersion === 3) { |
| 19 | + window.MathJax = { |
| 20 | + startup: { |
| 21 | + output: 'chtml', |
| 22 | + tex: { |
| 23 | + inlineMath: ['|', '|'] |
| 24 | + } |
| 25 | + } |
| 26 | + }; |
| 27 | + } |
| 28 | + |
| 29 | + var src = mathjaxVersion === 3 ? |
| 30 | + '/base/node_modules/mathjax-v3/es5/tex-svg.js' : |
| 31 | + '/base/node_modules/mathjax-v2/MathJax.js?config=TeX-AMS_SVG'; |
| 32 | + |
| 33 | + loadScript(src, done); |
| 34 | + }); |
| 35 | + |
| 36 | + afterAll(destroyGraphDiv); |
| 37 | + |
| 38 | + it('should maintain startup renderer & inlineMath after SVG rendering', function(done) { |
| 39 | + if(mathjaxVersion === 2) { |
| 40 | + window.MathJax.Hub.Config({ |
| 41 | + tex2jax: { |
| 42 | + inlineMath: ['|', '|'] |
| 43 | + } |
| 44 | + }); |
| 45 | + |
| 46 | + window.MathJax.Hub.setRenderer('CHTML'); |
| 47 | + } |
| 48 | + |
| 49 | + Plotly.newPlot(gd, { |
| 50 | + data: [{ |
| 51 | + y: [1, 2] |
| 52 | + }], |
| 53 | + layout: { |
| 54 | + title: { |
| 55 | + text: '|E=mc^2|' |
| 56 | + } |
| 57 | + } |
| 58 | + }) |
| 59 | + .then(function() { |
| 60 | + if(mathjaxVersion === 3) { |
| 61 | + expect(window.MathJax.config.startup.tex.inlineMath).toEqual(['|', '|']); |
| 62 | + expect(window.MathJax.config.startup.output).toEqual('chtml'); |
| 63 | + } |
| 64 | + |
| 65 | + if(mathjaxVersion === 2) { |
| 66 | + expect(window.MathJax.Hub.config.tex2jax.inlineMath).toEqual(['|', '|']); |
| 67 | + expect(window.MathJax.Hub.config.menuSettings.renderer).toEqual(''); |
| 68 | + } |
| 69 | + }) |
| 70 | + .then(done, done.fail); |
| 71 | + }); |
| 72 | +}); |
0 commit comments