Added tests and cleaned up slice() command
diff --git a/src/commands/math/basicSymbols.js b/src/commands/math/basicSymbols.js
index 4fc0671..49198a4 100644
--- a/src/commands/math/basicSymbols.js
+++ b/src/commands/math/basicSymbols.js
@@ -29,7 +29,7 @@
text = text.slice(1, text.length);
}
else if (text[text.length-1] == ' ') {
- text = text.slice (0, text.length-1);
+ text = text.slice (0, -1);
}
} else {
if (this[L] && !(this[L] instanceof Variable)
diff --git a/test/unit/autoOperatorNames.test.js b/test/unit/autoOperatorNames.test.js
index eb7c21c..05ea189 100644
--- a/test/unit/autoOperatorNames.test.js
+++ b/test/unit/autoOperatorNames.test.js
@@ -14,6 +14,13 @@
);
}
+ function assertText(input, expected) {
+ var result = mq.text();
+ assert.equal(result, expected,
+ input+', got \''+result+'\', expected \''+expected+'\''
+ );
+ }
+
test('simple LaTeX parsing, typing', function() {
function assertAutoOperatorNamesWork(str, latex) {
var count = 0;
@@ -47,6 +54,16 @@
assertAutoOperatorNamesWork('scscscscscsc', 's\\csc s\\csc s\\csc');
});
+ test('text() output', function(){
+ function assertTranslatedCorrectly(latexStr, text) {
+ mq.latex(latexStr);
+ assertText('outputting ' + latexStr, text);
+ }
+
+ assertTranslatedCorrectly('\\sin', 'sin');
+ assertTranslatedCorrectly('\\sin\\left(xy\\right)', 'sin(x*y)');
+ });
+
test('deleting', function() {
var count = 0;
var _autoUnItalicize = Letter.prototype.autoUnItalicize;