|
1 | 1 | var d3Select = require('../../strict-d3').select; |
2 | 2 | var d3SelectAll = require('../../strict-d3').selectAll; |
3 | 3 |
|
| 4 | +var Plotly = require('../../../lib/index'); |
4 | 5 | var util = require('../../../src/lib/svg_text_utils'); |
5 | 6 |
|
| 7 | +var createGraphDiv = require('../assets/create_graph_div'); |
| 8 | +var destroyGraphDiv = require('../assets/destroy_graph_div'); |
| 9 | + |
6 | 10 |
|
7 | 11 | describe('svg+text utils', function() { |
8 | 12 | 'use strict'; |
@@ -619,3 +623,40 @@ describe('sanitizeHTML', function() { |
619 | 623 | expect(innerHTML).toEqual('<a href="https://example.com/?q=date%20%3E=%202018-01-01">click</a>'); |
620 | 624 | }); |
621 | 625 | }); |
| 626 | + |
| 627 | +// regression test for https://github.com/plotly/plotly.js/issues/7926 |
| 628 | +describe('convertToTspans with an unsupported MathJax version', function() { |
| 629 | + 'use strict'; |
| 630 | + |
| 631 | + var gd; |
| 632 | + var mathJaxBefore; |
| 633 | + |
| 634 | + beforeEach(function() { |
| 635 | + gd = createGraphDiv(); |
| 636 | + mathJaxBefore = window.MathJax; |
| 637 | + // Fake the presence of MathJax v2 by clearing window.MathJax |
| 638 | + // and setting window.MathJax.version to a v2.x version string |
| 639 | + window.MathJax = {version: '2.7.9'}; |
| 640 | + }); |
| 641 | + |
| 642 | + afterEach(function() { |
| 643 | + if(mathJaxBefore === undefined) delete window.MathJax; |
| 644 | + else window.MathJax = mathJaxBefore; |
| 645 | + destroyGraphDiv(); |
| 646 | + }); |
| 647 | + |
| 648 | + it('draws the plot with the tex left unevaluated', function(done) { |
| 649 | + Plotly.newPlot(gd, [{y: [1, 2, 3]}], {title: {text: '$x^2$'}}) |
| 650 | + .then(function() { |
| 651 | + // whole plot should render except for tex string |
| 652 | + expect(d3SelectAll('.scatterlayer .trace').size()).toBe(1, 'trace'); |
| 653 | + expect(d3SelectAll('.xtick').size()).toBeGreaterThan(0, 'x ticks'); |
| 654 | + |
| 655 | + var title = d3Select('.gtitle'); |
| 656 | + expect(title.size()).toBe(1, 'title'); |
| 657 | + expect(title.text()).toBe('$x^2$', 'raw tex as title'); |
| 658 | + expect(title.node().style.display).not.toBe('none', 'title is visible'); |
| 659 | + }) |
| 660 | + .then(done, done.fail); |
| 661 | + }); |
| 662 | +}); |
0 commit comments