mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-13 08:39:21 -05:00
28 lines
1 KiB
JavaScript
28 lines
1 KiB
JavaScript
|
// @ts-check
|
||
|
|
||
|
const { expect } = require('chai')
|
||
|
const Utils = require('../../../app/js/Utils')
|
||
|
|
||
|
describe('Utils', function () {
|
||
|
describe('addTrackedDeletesToContent', function () {
|
||
|
it("doesn't modify text without tracked deletes", function () {
|
||
|
const content = 'the quick brown fox'
|
||
|
const trackedChanges = []
|
||
|
const result = Utils.addTrackedDeletesToContent(content, trackedChanges)
|
||
|
expect(result).to.equal(content)
|
||
|
})
|
||
|
|
||
|
it('adds tracked deletes to text but skips tracked inserts', function () {
|
||
|
const content = 'the brown fox jumps over the dog'
|
||
|
const metadata = { user_id: 'user1', ts: new Date().toString() }
|
||
|
const trackedChanges = [
|
||
|
{ id: 'tc1', op: { d: 'quick ', p: 4 }, metadata },
|
||
|
{ id: 'tc2', op: { i: 'brown ', p: 5 }, metadata },
|
||
|
{ id: 'tc3', op: { d: 'lazy ', p: 29 }, metadata },
|
||
|
]
|
||
|
const result = Utils.addTrackedDeletesToContent(content, trackedChanges)
|
||
|
expect(result).to.equal('the quick brown fox jumps over the lazy dog')
|
||
|
})
|
||
|
})
|
||
|
})
|