Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@emertechie
Created March 4, 2014 13:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emertechie/9346336 to your computer and use it in GitHub Desktop.
Save emertechie/9346336 to your computer and use it in GitHub Desktop.
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