|
|
@@ -67,7 +67,7 @@ describe('persistChanges', function () {
|
|
|
expect(chunk.getChanges().length).to.equal(1)
|
|
|
})
|
|
|
|
|
|
- it('persists changes in two chunks', async function () {
|
|
|
+ it('persists changes in three chunks', async function () {
|
|
|
const limitsToPersistImmediately = {
|
|
|
maxChunkChanges: 1,
|
|
|
minChangeTimestamp: farFuture,
|
|
|
@@ -84,7 +84,12 @@ describe('persistChanges', function () {
|
|
|
new Date(),
|
|
|
[]
|
|
|
)
|
|
|
- const changes = [firstChange, secondChange]
|
|
|
+ const thirdChange = new Change(
|
|
|
+ [new AddFileOperation('c.tex', File.fromString(''))],
|
|
|
+ new Date(),
|
|
|
+ []
|
|
|
+ )
|
|
|
+ const changes = [firstChange, secondChange, thirdChange]
|
|
|
|
|
|
await chunkStore.initializeProject(projectId)
|
|
|
const result = await persistChanges(
|
|
|
@@ -99,20 +104,23 @@ describe('persistChanges', function () {
|
|
|
'a.tex': {
|
|
|
content: '',
|
|
|
},
|
|
|
+ 'b.tex': {
|
|
|
+ content: '',
|
|
|
+ },
|
|
|
},
|
|
|
})
|
|
|
- const history = new History(snapshot, [secondChange])
|
|
|
- const currentChunk = new Chunk(history, 1)
|
|
|
+ const history = new History(snapshot, [thirdChange])
|
|
|
+ const currentChunk = new Chunk(history, 2)
|
|
|
expect(result).to.deep.equal({
|
|
|
- numberOfChangesPersisted: 2,
|
|
|
+ numberOfChangesPersisted: 3,
|
|
|
originalEndVersion: 0,
|
|
|
currentChunk,
|
|
|
resyncNeeded: false,
|
|
|
})
|
|
|
|
|
|
const chunk = await chunkStore.loadLatest(projectId)
|
|
|
- expect(chunk.getStartVersion()).to.equal(1)
|
|
|
- expect(chunk.getEndVersion()).to.equal(2)
|
|
|
+ expect(chunk.getStartVersion()).to.equal(2)
|
|
|
+ expect(chunk.getEndVersion()).to.equal(3)
|
|
|
expect(chunk.getChanges().length).to.equal(1)
|
|
|
})
|
|
|
|