mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-28 11:26:16 -04:00
first version after migration to mocha
This commit is contained in:
parent
876d7db39a
commit
5becf0bd15
13 changed files with 1222 additions and 1613 deletions
46
tests/backend/specs/easysync/makeattribsstring.js
Normal file
46
tests/backend/specs/easysync/makeattribsstring.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
|
||||
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;
|
||||
describe("make attribs string",function(){
|
||||
it("make attribs string",function(done){
|
||||
testMakeAttribsString(1, ['bold,'], '+', [
|
||||
['bold', '']
|
||||
], '');
|
||||
testMakeAttribsString(2, ['abc,def', 'bold,'], '=', [
|
||||
['bold', '']
|
||||
], '*1');
|
||||
testMakeAttribsString(3, ['abc,def', 'bold,true'], '+', [
|
||||
['abc', 'def'],
|
||||
['bold', 'true']
|
||||
], '*0*1');
|
||||
testMakeAttribsString(4, ['abc,def', 'bold,true'], '+', [
|
||||
['bold', 'true'],
|
||||
['abc', 'def']
|
||||
], '*0*1');
|
||||
|
||||
done()
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
function testMakeAttribsString(testId, pool, opcode, attribs, correctString) {
|
||||
|
||||
var p = poolOrArray(pool);
|
||||
var str = Changeset.makeAttribsString(opcode, attribs, p);
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue