mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-28 11:26:16 -04:00
move duplicated code to helper.js
This commit is contained in:
parent
dcb061fb1b
commit
2af8948f68
8 changed files with 248 additions and 672 deletions
|
@ -2,6 +2,9 @@ var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
|||
var helper = require("./helper.js")
|
||||
var assertEqualStrings = helper.assertEqualStrings;
|
||||
var assertEqualArrays = helper.assertEqualArrays;
|
||||
var random = helper.random;
|
||||
var randomMultiline = helper.randomMultiline;
|
||||
var randomInlineString = helper.randomInlineString;
|
||||
|
||||
describe("testSplitJoinAttributionLines",function(){
|
||||
it("testSplitJoinAttributionLines",function(done){
|
||||
|
@ -35,32 +38,3 @@ describe("testSplitJoinAttributionLines",function(){
|
|||
assertEqualStrings(theJoined, Changeset.joinAttributionLines(theSplit));
|
||||
}
|
||||
|
||||
function random() {
|
||||
this.nextInt = function (maxValue) {
|
||||
return Math.floor(Math.random() * maxValue);
|
||||
}
|
||||
}
|
||||
function randomMultiline(approxMaxLines, approxMaxCols, rand) {
|
||||
var numParts = rand.nextInt(approxMaxLines * 2) + 1;
|
||||
var txt = Changeset.stringAssembler();
|
||||
txt.append(rand.nextInt(2) ? '\n' : '');
|
||||
for (var i = 0; i < numParts; i++) {
|
||||
if ((i % 2) == 0) {
|
||||
if (rand.nextInt(10)) {
|
||||
txt.append(randomInlineString(rand.nextInt(approxMaxCols) + 1, rand));
|
||||
} else {
|
||||
txt.append('\n');
|
||||
}
|
||||
} else {
|
||||
txt.append('\n');
|
||||
}
|
||||
}
|
||||
return txt.toString();
|
||||
}
|
||||
function randomInlineString(len, rand) {
|
||||
var assem = Changeset.stringAssembler();
|
||||
for (var i = 0; i < len; i++) {
|
||||
assem.append(String.fromCharCode(rand.nextInt(26) + 97));
|
||||
}
|
||||
return assem.toString();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue