mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-28 11:26:16 -04:00
import initial migration work
This commit is contained in:
parent
451b82536a
commit
172256d69a
2 changed files with 938 additions and 0 deletions
37
tests/backend/specs/easysync/helper.js
Normal file
37
tests/backend/specs/easysync/helper.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
exports.assert = function (code, optMsg) {
|
||||
if (!eval(code)) throw new Error("FALSE: " + (optMsg || code));
|
||||
};
|
||||
|
||||
exports.literal = function (v) {
|
||||
if ((typeof v) == "string") {
|
||||
return '"' + v.replace(/[\\\"]/g, '\\$1').replace(/\n/g, '\\n') + '"';
|
||||
} else
|
||||
return JSON.stringify(v);
|
||||
}
|
||||
|
||||
exports.assertEqualArrays = function (a, b) {
|
||||
exports.assert("JSON.stringify(" + exports.literal(a) + ") == JSON.stringify(" + exports.literal(b) + ")");
|
||||
}
|
||||
|
||||
exports.assertEqualStrings = function (a, b) {
|
||||
exports.assert(exports.literal(a) + " == " + exports.literal(b));
|
||||
}
|
||||
|
||||
exports.throughIterator = function (opsStr) {
|
||||
var iter = Changeset.opIterator(opsStr);
|
||||
var assem = Changeset.opAssembler();
|
||||
while (iter.hasNext()) {
|
||||
assem.append(iter.next());
|
||||
}
|
||||
return assem.toString();
|
||||
}
|
||||
|
||||
exports.throughSmartAssembler = function (opsStr) {
|
||||
var iter = Changeset.opIterator(opsStr);
|
||||
var assem = Changeset.smartOpAssembler();
|
||||
while (iter.hasNext()) {
|
||||
assem.append(iter.next());
|
||||
}
|
||||
assem.endDocument();
|
||||
return assem.toString();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue