move duplicated code to helper.js

This commit is contained in:
webzwo0i 2020-08-04 19:01:42 +02:00
parent dcb061fb1b
commit 2af8948f68
8 changed files with 248 additions and 672 deletions

View file

@ -1,8 +1,7 @@
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
var AttributePool = require("ep_etherpad-lite/static/js/AttributePool");
var helper = require("./helper.js")
var assertEqualStrings = helper.assertEqualStrings;
var poolOrArray = helper.poolOrArray;
describe("make attribs string",function(){
it("make attribs string",function(done){
testMakeAttribsString(1, ['bold,'], '+', [
@ -32,15 +31,3 @@ describe("make attribs string",function(){
assertEqualStrings(correctString, str);
}
function poolOrArray(attribs) {
if (attribs.getAttrib) {
return attribs; // it's already an attrib pool
} else {
// assume it's an array of attrib strings to be split and added
var p = new AttributePool();
attribs.forEach(function (kv) {
p.putAttrib(kv.split(','));
});
return p;
}
}