UNPKG

easy-mathjax

Version:
72 lines (71 loc) 2.22 kB
describe("EasyMathJax suite", function() { var div, e; div = null; e = null; beforeEach(function() { var _ref; if (div != null) { if ((_ref = div.parentNode) != null) { _ref.removeChild(div); } } div = document.createElement("div"); div.className = "EasyMathJax-Test"; return document.body.appendChild(div); }); it("Exports constructor globally.", function() { return expect(typeof EasyMathJax).toBe("function"); }); it("Respects user-provided options.", function() { e = new EasyMathJax({ url: "MathJax.js" }); return expect(e.options.url).toBe("MathJax.js"); }); it("Injects MathJax properly.", function(done) { e = new EasyMathJax({ config: { tex2jax: { inlineMath: [["~", "~"]], displayMath: [["~~~", "~~~"]] } } }); e.inject(function() { return done(); }); return expect(e.script).toBeDefined(); }); it("Renders math correctly.", function(done) { div.textContent = "Testing some math ~ A^3 ~ inlined"; return e.render(".EasyMathJax-Test", function() { var script; script = div.querySelector("script[type='math/tex']"); expect(script).not.toBe(null); expect(script.textContent).toBe(" A^3 "); return done(); }); }); it("Exports css data after render.", function(done) { div.textContent = "Testing some math ~ A^3 ~ inlined"; return e.render(".EasyMathJax-Test", function() { var css; css = e.css(); expect(css.contents.replace(/\s\n/g, "")).not.toBe(""); expect(typeof css.fonts).toBe("object"); expect(Object.keys(css.fonts).length).not.toBe(0); return done(); }); }); return it("Cleans up the document.", function(done) { div.textContent = "Testing some math ~ A^3 ~ inlined"; return e.render(".EasyMathJax-Test", function() { e.clean(); expect(document.querySelector("script[type='math/tex']")).toBe(null); expect(document.querySelector(".MathJax_Preview")).toBe(null); expect(document.querySelector("#MathJax_Font_Test")).toBe(null); expect(e.script.parentNode).toBe(null); return done(); }); }); });