mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
Merge pull request #17678 from overleaf/em-diff-as-share-js-ops
Make diffAsShareJsOps() synchronous GitOrigin-RevId: 5a3f96cc2f4b81e27a4ee971667f52c48c07e938
This commit is contained in:
@@ -1,14 +1,3 @@
|
||||
/* eslint-disable
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
*/
|
||||
// TODO: This file was created by bulk-decaffeinate.
|
||||
// Fix any style issues and re-enable lint.
|
||||
/*
|
||||
* decaffeinate suggestions:
|
||||
* DS102: Remove unnecessary code created because of implicit returns
|
||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||
*/
|
||||
const sinon = require('sinon')
|
||||
const { expect } = require('chai')
|
||||
const modulePath = '../../../../app/js/DiffCodec.js'
|
||||
@@ -17,80 +6,52 @@ const SandboxedModule = require('sandboxed-module')
|
||||
describe('DiffCodec', function () {
|
||||
beforeEach(function () {
|
||||
this.callback = sinon.stub()
|
||||
return (this.DiffCodec = SandboxedModule.require(modulePath))
|
||||
this.DiffCodec = SandboxedModule.require(modulePath)
|
||||
})
|
||||
|
||||
return describe('diffAsShareJsOps', function () {
|
||||
it('should insert new text correctly', function (done) {
|
||||
describe('diffAsShareJsOps', function () {
|
||||
it('should insert new text correctly', function () {
|
||||
this.before = ['hello world']
|
||||
this.after = ['hello beautiful world']
|
||||
return this.DiffCodec.diffAsShareJsOp(
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{
|
||||
i: 'beautiful ',
|
||||
p: 6,
|
||||
},
|
||||
])
|
||||
return done()
|
||||
}
|
||||
)
|
||||
const ops = this.DiffCodec.diffAsShareJsOp(this.before, this.after)
|
||||
expect(ops).to.deep.equal([
|
||||
{
|
||||
i: 'beautiful ',
|
||||
p: 6,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
it('should shift later inserts by previous inserts', function (done) {
|
||||
it('should shift later inserts by previous inserts', function () {
|
||||
this.before = ['the boy played with the ball']
|
||||
this.after = ['the tall boy played with the red ball']
|
||||
return this.DiffCodec.diffAsShareJsOp(
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{ i: 'tall ', p: 4 },
|
||||
{ i: 'red ', p: 29 },
|
||||
])
|
||||
return done()
|
||||
}
|
||||
)
|
||||
const ops = this.DiffCodec.diffAsShareJsOp(this.before, this.after)
|
||||
expect(ops).to.deep.equal([
|
||||
{ i: 'tall ', p: 4 },
|
||||
{ i: 'red ', p: 29 },
|
||||
])
|
||||
})
|
||||
|
||||
it('should delete text correctly', function (done) {
|
||||
it('should delete text correctly', function () {
|
||||
this.before = ['hello beautiful world']
|
||||
this.after = ['hello world']
|
||||
return this.DiffCodec.diffAsShareJsOp(
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{
|
||||
d: 'beautiful ',
|
||||
p: 6,
|
||||
},
|
||||
])
|
||||
return done()
|
||||
}
|
||||
)
|
||||
const ops = this.DiffCodec.diffAsShareJsOp(this.before, this.after)
|
||||
expect(ops).to.deep.equal([
|
||||
{
|
||||
d: 'beautiful ',
|
||||
p: 6,
|
||||
},
|
||||
])
|
||||
})
|
||||
|
||||
return it('should shift later deletes by the first deletes', function (done) {
|
||||
it('should shift later deletes by the first deletes', function () {
|
||||
this.before = ['the tall boy played with the red ball']
|
||||
this.after = ['the boy played with the ball']
|
||||
return this.DiffCodec.diffAsShareJsOp(
|
||||
this.before,
|
||||
this.after,
|
||||
(error, ops) => {
|
||||
if (error) return done(error)
|
||||
expect(ops).to.deep.equal([
|
||||
{ d: 'tall ', p: 4 },
|
||||
{ d: 'red ', p: 24 },
|
||||
])
|
||||
return done()
|
||||
}
|
||||
)
|
||||
const ops = this.DiffCodec.diffAsShareJsOp(this.before, this.after)
|
||||
expect(ops).to.deep.equal([
|
||||
{ d: 'tall ', p: 4 },
|
||||
{ d: 'red ', p: 24 },
|
||||
])
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user