migrate more tests to mocha

This commit is contained in:
webzwo0i 2016-02-29 18:30:16 +01:00
parent 6f1b0d9185
commit 0db329e1b3

View file

@ -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);