Created
March 4, 2014 13:15
-
-
Save emertechie/9346336 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define([ | |
'parse' | |
], function() { | |
describe('Quick & Dirty Parse Conflict Test', function() { | |
var async = new AsyncSpec(this); | |
var TestObject; | |
beforeEach(function() { | |
TestObject = Parse.Object.extend("TestObject"); | |
var appId = "<your app ID here>"; | |
var key = "<your key here>"; | |
Parse.initialize(appId, key); | |
}); | |
async.it('Can detect stale update', function(done) { | |
var obj = new TestObject({ | |
name: 'foo' | |
}); | |
obj.save(null, { | |
success: function(addedObj) { | |
var cloned = new TestObject(JSON.parse(JSON.stringify(addedObj))); | |
addedObj.set('name', 'Edit1'); | |
addedObj.save(null, { | |
success: function() { | |
cloned.set('name', 'Edit2'); | |
cloned.save(null, { | |
success: function() { | |
expect('should not get here').toBeUndefined(); | |
done(); | |
}, | |
error: function(obj, err) { | |
console.info('Error was: ' + JSON.stringify(err)); | |
expect(err.message.indexOf('StaleUpdate:')).toBe(0); | |
done(); | |
} | |
}); | |
} | |
}); | |
} | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment