|
|
@@ -109,11 +109,40 @@ describe('Applying updates to a doc', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+ it('should yield last updated time', function (done) {
|
|
|
+ DocUpdaterClient.getProjectLastUpdatedAt(
|
|
|
+ this.project_id,
|
|
|
+ (error, res, body) => {
|
|
|
+ if (error != null) {
|
|
|
+ throw error
|
|
|
+ }
|
|
|
+ res.statusCode.should.equal(200)
|
|
|
+ body.lastUpdatedAt.should.be.within(this.startTime, Date.now())
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('should yield no last updated time for another project', function (done) {
|
|
|
+ DocUpdaterClient.getProjectLastUpdatedAt(
|
|
|
+ DocUpdaterClient.randomId(),
|
|
|
+ (error, res, body) => {
|
|
|
+ if (error != null) {
|
|
|
+ throw error
|
|
|
+ }
|
|
|
+ res.statusCode.should.equal(200)
|
|
|
+ body.should.deep.equal({})
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
describe('when sending another update', function () {
|
|
|
before(function (done) {
|
|
|
- this.timeout = 10000
|
|
|
- this.second_update = Object.create(this.update)
|
|
|
+ this.timeout(10000)
|
|
|
+ this.second_update = Object.assign({}, this.update)
|
|
|
this.second_update.v = this.version + 1
|
|
|
+ this.secondStartTime = Date.now()
|
|
|
DocUpdaterClient.sendUpdate(
|
|
|
this.project_id,
|
|
|
this.doc_id,
|
|
|
@@ -127,6 +156,24 @@ describe('Applying updates to a doc', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+ it('should update the doc', function (done) {
|
|
|
+ DocUpdaterClient.getDoc(
|
|
|
+ this.project_id,
|
|
|
+ this.doc_id,
|
|
|
+ (error, res, doc) => {
|
|
|
+ if (error) done(error)
|
|
|
+ doc.lines.should.deep.equal([
|
|
|
+ 'one',
|
|
|
+ 'one and a half',
|
|
|
+ 'one and a half',
|
|
|
+ 'two',
|
|
|
+ 'three',
|
|
|
+ ])
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
it('should not change the first op timestamp', function (done) {
|
|
|
rclientProjectHistory.get(
|
|
|
ProjectHistoryKeys.projectHistoryFirstOpTimestamp({
|
|
|
@@ -142,6 +189,23 @@ describe('Applying updates to a doc', function () {
|
|
|
}
|
|
|
)
|
|
|
})
|
|
|
+
|
|
|
+ it('should yield last updated time', function (done) {
|
|
|
+ DocUpdaterClient.getProjectLastUpdatedAt(
|
|
|
+ this.project_id,
|
|
|
+ (error, res, body) => {
|
|
|
+ if (error != null) {
|
|
|
+ throw error
|
|
|
+ }
|
|
|
+ res.statusCode.should.equal(200)
|
|
|
+ body.lastUpdatedAt.should.be.within(
|
|
|
+ this.secondStartTime,
|
|
|
+ Date.now()
|
|
|
+ )
|
|
|
+ done()
|
|
|
+ }
|
|
|
+ )
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
|