update tests

This commit is contained in:
nightwing 2012-07-16 00:47:47 +04:00
commit 5e7434bdbb
4 changed files with 39 additions and 14 deletions

View file

@ -196,6 +196,7 @@ var Text = function(parentEl) {
this.setSession = function(session) {
this.session = session;
this.$computeTabString();
};
this.showInvisibles = false;
@ -244,8 +245,8 @@ var Text = function(parentEl) {
tabContent = this.TAB_CHAR + content.substr(6);
}
this.$tabStrings[" "] = "<span class='" + className + "' >" + content + "</span>";
this.$tabStrings["\t"] = "<span class='" + className + "' >" + tabContent + "</span>";
this.$tabStrings[" "] = "<span class='" + className + "'>" + content + "</span>";
this.$tabStrings["\t"] = "<span class='" + className + "'>" + tabContent + "</span>";
}
};

View file

@ -67,35 +67,61 @@ module.exports = {
this.textLayer.$computeTabString();
// row with hard tabs
var row = 0;
var tokens = this.session.getTokens(row);
var stringBuilder = [];
this.textLayer.$renderLine(stringBuilder, row, tokens);
this.textLayer.$renderLine(stringBuilder, 0);
// row with soft tabs
row = 1;
tokens = this.session.getTokens(row);
var stringBuilder2 = [];
this.textLayer.$renderLine(stringBuilder2, row, tokens);
this.textLayer.$renderLine(stringBuilder2, 1);
assert.equal(stringBuilder.join(""), stringBuilder2.join(""));
},
"test rendering width of ideographic space (U+3000)" : function() {
this.session.setValue("\u3000");
var tokens = this.session.getTokens(0);
var stringBuilder = [];
this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
this.textLayer.$renderLine(stringBuilder, 0, true);
assert.equal(stringBuilder.join(""), "<span class='ace_cjk' style='width:20px'></span>");
this.textLayer.setShowInvisibles(true);
var stringBuilder = [];
this.textLayer.$renderLine(stringBuilder, 0, tokens, true);
this.textLayer.$renderLine(stringBuilder, 0, true);
assert.equal(
stringBuilder.join(""),
"<span class='ace_cjk ace_invisible' style='width:20px'>" + this.textLayer.SPACE_CHAR + "</span>"
+ "<span class='ace_invisible'>\xB6</span>"
);
},
"test rendering of indent guides" : function() {
var textLayer = this.textLayer
var EOL = "<span class='ace_invisible'>" + textLayer.EOL_CHAR + "</span>";
var SPACE = function(i) {return Array(i+1).join("&#160;")}
var TAB = function(i) {return textLayer.TAB_CHAR + SPACE(i-1)}
function testRender(results) {
for (var i = results.length; i--; ) {
var stringBuilder = [];
textLayer.$renderLine(stringBuilder, i, true);
assert.equal(stringBuilder.join(""), results[i]);
}
}
this.session.setValue(" \n\t\tf\n ");
testRender([
"<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(2),
"<span class='ace_indent-guide'>" + SPACE(4) + "</span>" + SPACE(4) + "<span class='ace_identifier'>f</span>",
SPACE(3)
]);
this.textLayer.setShowInvisibles(true);
testRender([
"<span class='ace_indent-guide ace_invisible'>" + SPACE(4) + "</span>" + SPACE(2) + EOL,
"<span class='ace_indent-guide ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL,
]);
this.textLayer.setDisplayIndentGuides(false);
testRender([
SPACE(6) + EOL,
"<span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_invisible'>" + TAB(4) + "</span><span class='ace_identifier'>f</span>" + EOL
]);
}
};