Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should handle code spans', () => {
let input = '`$foo` and `$bar` are variables';
let { text, math } = removeMath(input);
expect(text).to.be(input);
expect(math).to.eql([]);
});
it('should handle begin statements', () => {
let input = 'hello, \\begin{align} \\end{align}, there';
let { text, math } = removeMath(input);
expect(text).to.be('hello, @@0@@, there');
expect(math).to.eql(['\\begin{align} \\end{align}'])
});
it('should handle unbalanced braces', () => {
let input = 'hello, $ /alpha { $, there';
let { text, math } = removeMath(input);
expect(text).to.be('hello, @@0@@, there');
expect(math).to.eql(['$ /alpha { $' ])
});
it('should recombine text split with removeMath', () => {
let input = 'hello, $ /alpha $, there';
let { text, math } = removeMath(input);
expect(replaceMath(text, math)).to.be(input);
});
it('should handle math blocks', () => {
let input = 'hello, $$\nfoo\n$$, there';
let { text, math } = removeMath(input);
expect(text).to.be('hello, @@0@@, there');
expect(math).to.eql(['$$\nfoo\n$$' ])
});
it('should handle balanced braces', () => {
let input = 'hello, $ /alpha { } $, there';
let { text, math } = removeMath(input);
expect(text).to.be('hello, @@0@@, there');
expect(math).to.eql(['$ /alpha { } $' ])
});
it('should handle math markers', () => {
let input = ' @@0@@ hello, $ /alpha $, there';
let { text, math } = removeMath(input);
expect(text).to.be(' @@0@@ hello, @@1@@, there');
expect(math).to.eql([ '@@0@@', '$ /alpha $' ])
});
it('should handle `\\\\\[` delimiters for math', () => {
let input = `hello, \\\\\[
/alpha
\\\\\], there`;
let { text, math } = removeMath(input);
expect(text).to.be('hello, @@0@@, there');
expect(math).to.eql(['\\\\[\n /alpha\n \\\\]']);
});