mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add tests for _s3DocToMongo
This commit is contained in:
parent
f94e33a3a9
commit
bf187f30ec
1 changed files with 42 additions and 0 deletions
|
@ -212,3 +212,45 @@ describe "DocArchiveManager", ->
|
|||
@DocArchiveManager.unArchiveAllDocs @project_id, (err)=>
|
||||
err.should.equal @error
|
||||
done()
|
||||
|
||||
describe "_s3DocToMongoDoc", ->
|
||||
describe "with the old schema", ->
|
||||
it "should return the docs lines", (done) ->
|
||||
@DocArchiveManager._s3DocToMongoDoc ["doc", "lines"], (error, doc) ->
|
||||
expect(doc).to.deep.equal {
|
||||
lines: ["doc", "lines"]
|
||||
}
|
||||
done()
|
||||
|
||||
describe "with the new schema", ->
|
||||
it "should return the doc lines and ranges", (done) ->
|
||||
@RangeManager.jsonRangesToMongo = sinon.stub().returns {"mongo": "ranges"}
|
||||
@DocArchiveManager._s3DocToMongoDoc {
|
||||
lines: ["doc", "lines"]
|
||||
ranges: {"json": "ranges"}
|
||||
schema_v: 1
|
||||
}, (error, doc) ->
|
||||
expect(doc).to.deep.equal {
|
||||
lines: ["doc", "lines"]
|
||||
ranges: {"mongo": "ranges"}
|
||||
}
|
||||
done()
|
||||
|
||||
it "should return just the doc lines when there are no ranges", (done) ->
|
||||
@DocArchiveManager._s3DocToMongoDoc {
|
||||
lines: ["doc", "lines"]
|
||||
schema_v: 1
|
||||
}, (error, doc) ->
|
||||
expect(doc).to.deep.equal {
|
||||
lines: ["doc", "lines"]
|
||||
}
|
||||
done()
|
||||
|
||||
describe "with an unrecognised schema", ->
|
||||
it "should return an error", (done) ->
|
||||
@DocArchiveManager._s3DocToMongoDoc {
|
||||
schema_v: 2
|
||||
}, (error, doc) ->
|
||||
expect(error).to.exist
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in a new issue