Comparing version 1.0.1 to 1.0.2
{ | ||
"name": "diffsync", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Real time collaborative editing for JSON objects", | ||
@@ -15,2 +15,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"amp-is-array": "^1.0.1", | ||
"amp-is-object": "^1.0.1", | ||
"mocha": "^2.2.4", | ||
@@ -17,0 +19,0 @@ "sinon": "^1.14.1" |
var assert = require('assert'), | ||
sinon = require('sinon'), | ||
_ = require('underscore'), | ||
isEmpty = require('amp-is-empty'), | ||
jsondiffpatch = require('jsondiffpatch').create({ | ||
@@ -15,4 +15,4 @@ objectHash: function(obj) { return obj.id || obj._id || JSON.stringify(obj); } | ||
return new Client({ | ||
emit: _.noop, | ||
on: _.noop | ||
emit: function(){}, | ||
on: function(){} | ||
}, 'testroom'); | ||
@@ -132,3 +132,3 @@ }; | ||
assert(_.isEmpty(diff)); | ||
assert(isEmpty(diff)); | ||
}); | ||
@@ -141,3 +141,3 @@ | ||
assert(!_.isEmpty(diff)); | ||
assert(!isEmpty(diff)); | ||
}); | ||
@@ -300,3 +300,3 @@ }); | ||
// too lazy to add real diffs here | ||
client.applyServerEdit = _.noop; | ||
client.applyServerEdit = function(){}; | ||
@@ -303,0 +303,0 @@ client.doc.edits = [{}]; |
var assert = require('assert'), | ||
sinon = require('sinon'), | ||
_ = require('underscore'), | ||
isArray = require('amp-is-array'), | ||
isObject = require('amp-is-object'), | ||
jsondiffpatch = require('jsondiffpatch').create({ | ||
@@ -18,5 +19,5 @@ objectHash: function(obj) { return obj.id || obj._id || JSON.stringify(obj); } | ||
id: Math.random() + '', | ||
on: _.noop, | ||
emit: _.noop, | ||
join: _.noop, | ||
on: function(){}, | ||
emit: function(){}, | ||
join: function(){}, | ||
to: function(){ | ||
@@ -68,6 +69,6 @@ return new EventEmitter(); | ||
var server = testServer(), | ||
joinSpy = sinon.stub(server, 'joinConnection', _.noop), | ||
syncSpy = sinon.stub(server, 'receiveEdit', _.noop), | ||
joinSpy = sinon.stub(server, 'joinConnection', function(){}), | ||
syncSpy = sinon.stub(server, 'receiveEdit', function(){}), | ||
testEdit = {}, | ||
testCb = _.noop; | ||
testCb = function(){}; | ||
@@ -134,5 +135,5 @@ server.trackConnection(connection); | ||
assert(spy.called, 'called the callback'); | ||
assert(_.isArray(server.data[testRoom].registeredSockets), 'correct data in `serverCopy`'); | ||
assert(_.isObject(server.data[testRoom].clientVersions), 'correct data in `clientVersions`'); | ||
assert(_.isObject(server.data[testRoom].serverCopy), 'correct data in `serverCopy`'); | ||
assert(isArray(server.data[testRoom].registeredSockets), 'correct data in `serverCopy`'); | ||
assert(isObject(server.data[testRoom].clientVersions), 'correct data in `clientVersions`'); | ||
assert(isObject(server.data[testRoom].serverCopy), 'correct data in `serverCopy`'); | ||
assert(server.data[testRoom].serverCopy === data, 'correct value of data in `serverCopy`'); | ||
@@ -153,3 +154,3 @@ }); | ||
server.joinConnection({}, testRoom, _.noop); | ||
server.joinConnection({}, testRoom, function(){}); | ||
@@ -218,9 +219,9 @@ assert(getDataSpy.called); | ||
var join = function(){ | ||
server.joinConnection(connection, testRoom, _.noop); | ||
server.joinConnection(connection, testRoom, function(){}); | ||
}; | ||
it('gets data from the correct coom', function(){ | ||
var getDataSpy = sinon.stub(server, 'getData', _.noop); | ||
var getDataSpy = sinon.stub(server, 'getData', function(){}); | ||
server.receiveEdit(connection, editMessage, _.noop); | ||
server.receiveEdit(connection, editMessage, function(){}); | ||
@@ -234,3 +235,3 @@ assert(getDataSpy.called); | ||
server.receiveEdit(connection, editMessage, _.noop); | ||
server.receiveEdit(connection, editMessage, function(){}); | ||
@@ -243,3 +244,3 @@ assert(emitSpy.called); | ||
var saveSnapshotSpy = sinon.spy(server, 'saveSnapshot'), | ||
sendServerChangesSpy = sinon.stub(server, 'sendServerChanges', _.noop), | ||
sendServerChangesSpy = sinon.stub(server, 'sendServerChanges', function(){}), | ||
initialLocalVersion = 0, | ||
@@ -249,3 +250,3 @@ clientDoc, serverDoc; | ||
join(); | ||
server.receiveEdit(connection, editMessage, _.noop); | ||
server.receiveEdit(connection, editMessage, function(){}); | ||
@@ -285,3 +286,3 @@ serverDoc = server.data[testRoom]; | ||
describe('sendServerChanges', function(){ | ||
var send = _.noop, | ||
var send = function(){}, | ||
clientDoc, doc, server; | ||
@@ -288,0 +289,0 @@ |
40056
968
4