mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-28 03:16:16 -04:00
migrate more tests to mocha
This commit is contained in:
parent
6f1b0d9185
commit
0db329e1b3
1 changed files with 38 additions and 25 deletions
|
@ -286,7 +286,7 @@ describe("text line mutations",function(){
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
function poolOrArray(attribs) {
|
function poolOrArray(attribs) {
|
||||||
if (attribs.getAttrib) {
|
if (attribs.getAttrib) {
|
||||||
return attribs; // it's already an attrib pool
|
return attribs; // it's already an attrib pool
|
||||||
} else {
|
} else {
|
||||||
|
@ -297,22 +297,34 @@ describe("text line mutations",function(){
|
||||||
});
|
});
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function runApplyToAttributionTest(testId, attribs, cs, inAttr, outCorrect) {
|
function runApplyToAttributionTest(attribs, cs, inAttr) {
|
||||||
var p = poolOrArray(attribs);
|
var p = poolOrArray(attribs);
|
||||||
var result = Changeset.applyToAttribution(
|
var result = Changeset.applyToAttribution(
|
||||||
Changeset.checkRep(cs), inAttr, p);
|
Changeset.checkRep(cs), inAttr, p);
|
||||||
assertEqualStrings(outCorrect, result);
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// turn c<b>a</b>ctus\n into a<b>c</b>tusabcd\n
|
describe("applyToAttribution",function(){
|
||||||
runApplyToAttributionTest(1, ['bold,', 'bold,true'], "Z:7>3-1*0=1*1=1=3+4$abcd", "+1*1+1|1+5", "+1*1+1|1+8");
|
// turn c<b>a</b>ctus\n into a<b>c</b>tusabcd\n
|
||||||
|
it(" #1",function(done){
|
||||||
|
var result = runApplyToAttributionTest(['bold,', 'bold,true'], "Z:7>3-1*0=1*1=1=3+4$abcd", "+1*1+1|1+5");
|
||||||
|
var expected = "+1*1+1|1+8";
|
||||||
|
if(!assertEqualStrings(expected, result)) throw new Error("applyToAttribution is wrong expected:"+expected+" got "+result);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
// turn "david\ngreenspan\n" into "<b>david\ngreen</b>\n"
|
||||||
|
it(" #2",function(done){
|
||||||
|
var result = runApplyToAttributionTest(['bold,', 'bold,true'], "Z:g<4*1|1=6*1=5-4$", "|2+g");
|
||||||
|
var expected = "*1|1+6*1+5|1+1";
|
||||||
|
if(!assertEqualStrings(expected, result)) throw new Error("applyToAttribution is wrong expected:"+expected+" got "+result);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// turn "david\ngreenspan\n" into "<b>david\ngreen</b>\n"
|
describe("textLinesMutator",function(){
|
||||||
runApplyToAttributionTest(2, ['bold,', 'bold,true'], "Z:g<4*1|1=6*1=5-4$", "|2+g", "*1|1+6*1+5|1+1");
|
it("hasMore indicates remaining characters",function(done){
|
||||||
|
|
||||||
(function () {
|
|
||||||
var lines = ["1\n", "2\n", "3\n", "4\n"];
|
var lines = ["1\n", "2\n", "3\n", "4\n"];
|
||||||
var mu;
|
var mu;
|
||||||
|
|
||||||
|
@ -350,8 +362,9 @@ describe("text line mutations",function(){
|
||||||
assert(mu.hasMore() + ' == false');
|
assert(mu.hasMore() + ' == false');
|
||||||
mu.close();
|
mu.close();
|
||||||
assert(mu.hasMore() + ' == false');
|
assert(mu.hasMore() + ' == false');
|
||||||
|
done();
|
||||||
})();
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function runMutateAttributionTest(testId, attribs, cs, alines, outCorrect) {
|
function runMutateAttributionTest(testId, attribs, cs, alines, outCorrect) {
|
||||||
var p = poolOrArray(attribs);
|
var p = poolOrArray(attribs);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue