Skip to content

Commit

Permalink
Add test for infixOperatorNames
Browse files Browse the repository at this point in the history
  • Loading branch information
jared-hughes committed Mar 5, 2024
1 parent bfab552 commit 13b6c44
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/unit/infixOperatorNames.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
suite('infixOperatorNames', function () {
const $ = window.test_only_jquery;
var mq;
setup(function () {
const autoOperatorNames = 'arcsinh sin with for';
const infixOperatorNames = 'with for';
const opts = { autoOperatorNames, infixOperatorNames };
mq = MQ.MathField($('<span></span>').appendTo('#mock')[0], opts);
});

function prayWellFormedPoint(pt) {
prayWellFormed(pt.parent, pt[L], pt[R]);
}
function assertLatex(latex) {
prayWellFormedPoint(mq.__controller.cursor);
assert.equal(mq.latex(), latex);
}

test('for stops scanning', function () {
mq.typedText('tfor1/');
assertLatex('t\\operatorname{for}\\frac{1}{ }');
});

test('sin does not stop scanning', function () {
mq.typedText('tsin1/');
assertLatex('\\frac{t\\sin1}{ }');
});

test('arcsinh does not stop scanning', function () {
mq.typedText('tarcsinh1/');
assertLatex('\\frac{t\\operatorname{arcsinh}1}{ }');
});

test('backspace invalidates word', function () {
mq.typedText('tfor1');
mq.keystroke('Home').keystroke('Right').keystroke('Del');
assertLatex('tor1');
mq.keystroke('End').typedText('/');
assertLatex('\\frac{tor1}{ }');
});
});

0 comments on commit 13b6c44

Please sign in to comment.