mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-14 20:40:17 -05:00
ee85d948e2
GitOrigin-RevId: ef2ef77e26df59d1af3df6dc664e284d3c70102d
42 lines
1.3 KiB
JavaScript
42 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
const { expect } = require('chai')
|
|
const core = require('..')
|
|
const Change = core.Change
|
|
const File = core.File
|
|
const History = core.History
|
|
const Operation = core.Operation
|
|
const Snapshot = core.Snapshot
|
|
|
|
describe('History', function () {
|
|
describe('findBlobHashes', function () {
|
|
it('finds blob hashes from snapshot and changes', function () {
|
|
const history = new History(new Snapshot(), [])
|
|
|
|
const blobHashes = new Set()
|
|
history.findBlobHashes(blobHashes)
|
|
expect(blobHashes.size).to.equal(0)
|
|
|
|
// Add a file with a hash to the snapshot.
|
|
history.getSnapshot().addFile('foo', File.fromHash(File.EMPTY_FILE_HASH))
|
|
history.findBlobHashes(blobHashes)
|
|
expect(Array.from(blobHashes)).to.have.members([File.EMPTY_FILE_HASH])
|
|
|
|
// Add a file with a hash to the changes.
|
|
const testHash = 'a'.repeat(40)
|
|
const change = Change.fromRaw({
|
|
operations: [],
|
|
timestamp: '2015-03-05T12:03:53.035Z',
|
|
authors: [null],
|
|
})
|
|
change.pushOperation(Operation.addFile('bar', File.fromHash(testHash)))
|
|
|
|
history.pushChanges([change])
|
|
history.findBlobHashes(blobHashes)
|
|
expect(Array.from(blobHashes)).to.have.members([
|
|
File.EMPTY_FILE_HASH,
|
|
testHash,
|
|
])
|
|
})
|
|
})
|
|
})
|