mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-10 08:55:00 -04:00
easysync tests: Split into multiple files
This commit is contained in:
parent
617515bcbb
commit
0983985dd5
9 changed files with 973 additions and 962 deletions
63
src/tests/frontend/specs/easysync-assembler.js
Normal file
63
src/tests/frontend/specs/easysync-assembler.js
Normal file
|
@ -0,0 +1,63 @@
|
|||
'use strict';
|
||||
|
||||
const Changeset = require('../../../static/js/Changeset');
|
||||
|
||||
describe('easysync-assembler', function () {
|
||||
it('opAssembler', async function () {
|
||||
const x = '-c*3*4+6|3=az*asdf0*1*2*3+1=1-1+1*0+1=1-1+1|c=c-1';
|
||||
const assem = Changeset.opAssembler();
|
||||
for (const op of Changeset.deserializeOps(x)) assem.append(op);
|
||||
expect(assem.toString()).to.equal(x);
|
||||
});
|
||||
|
||||
it('smartOpAssembler', async function () {
|
||||
const x = '-c*3*4+6|3=az*asdf0*1*2*3+1=1-1+1*0+1=1-1+1|c=c-1';
|
||||
const assem = Changeset.smartOpAssembler();
|
||||
for (const op of Changeset.deserializeOps(x)) assem.append(op);
|
||||
assem.endDocument();
|
||||
expect(assem.toString()).to.equal(x);
|
||||
});
|
||||
|
||||
describe('append atext to assembler', function () {
|
||||
const testAppendATextToAssembler = (testId, atext, correctOps) => {
|
||||
it(`testAppendATextToAssembler#${testId}`, async function () {
|
||||
const assem = Changeset.smartOpAssembler();
|
||||
for (const op of Changeset.opsFromAText(atext)) assem.append(op);
|
||||
expect(assem.toString()).to.equal(correctOps);
|
||||
});
|
||||
};
|
||||
|
||||
testAppendATextToAssembler(1, {
|
||||
text: '\n',
|
||||
attribs: '|1+1',
|
||||
}, '');
|
||||
testAppendATextToAssembler(2, {
|
||||
text: '\n\n',
|
||||
attribs: '|2+2',
|
||||
}, '|1+1');
|
||||
testAppendATextToAssembler(3, {
|
||||
text: '\n\n',
|
||||
attribs: '*x|2+2',
|
||||
}, '*x|1+1');
|
||||
testAppendATextToAssembler(4, {
|
||||
text: '\n\n',
|
||||
attribs: '*x|1+1|1+1',
|
||||
}, '*x|1+1');
|
||||
testAppendATextToAssembler(5, {
|
||||
text: 'foo\n',
|
||||
attribs: '|1+4',
|
||||
}, '+3');
|
||||
testAppendATextToAssembler(6, {
|
||||
text: '\nfoo\n',
|
||||
attribs: '|2+5',
|
||||
}, '|1+1+3');
|
||||
testAppendATextToAssembler(7, {
|
||||
text: '\nfoo\n',
|
||||
attribs: '*x|2+5',
|
||||
}, '*x|1+1*x+3');
|
||||
testAppendATextToAssembler(8, {
|
||||
text: '\n\n\nfoo\n',
|
||||
attribs: '|2+2*x|2+5',
|
||||
}, '|2+2*x|1+1*x+3');
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue