mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-02-08 11:12:01 +01:00
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
|
|
var AttributePool = require("ep_etherpad-lite/static/js/AttributePool");
|
|
var Changeset = require("ep_etherpad-lite/static/js/Changeset");
|
|
var helper = require("./helper.js")
|
|
var assertEqualStrings = helper.assertEqualStrings;
|
|
|
|
describe("followAttributesTest",function(){
|
|
|
|
it("testFollow",function(done){
|
|
|
|
|
|
testFollow('', '', '', '', '');
|
|
testFollow('*0', '', '', '*0', '*0');
|
|
testFollow('*0', '*0', '', '', '*0');
|
|
testFollow('*0', '*1', '', '*0', '*0');
|
|
testFollow('*1', '*2', '', '*1', '*1');
|
|
testFollow('*0*1', '', '', '*0*1', '*0*1');
|
|
testFollow('*0*4', '*2*3', '*3', '*0', '*0*3');
|
|
testFollow('*0*4', '*2', '', '*0*4', '*0*4');
|
|
done();
|
|
})
|
|
|
|
})
|
|
|
|
function testFollow(a, b, afb, bfa, merge) {
|
|
var p = new AttributePool();
|
|
p.putAttrib(['x', '']);
|
|
p.putAttrib(['x', 'abc']);
|
|
p.putAttrib(['x', 'def']);
|
|
p.putAttrib(['y', '']);
|
|
p.putAttrib(['y', 'abc']);
|
|
p.putAttrib(['y', 'def']);
|
|
assertEqualStrings(afb, Changeset.followAttributes(a, b, p));
|
|
assertEqualStrings(bfa, Changeset.followAttributes(b, a, p));
|
|
assertEqualStrings(merge, Changeset.composeAttributes(a, afb, true, p));
|
|
assertEqualStrings(merge, Changeset.composeAttributes(b, bfa, true, p));
|
|
}
|
|
|