Created
February 25, 2012 13:38
-
-
Save diegoponciano/1908526 to your computer and use it in GitHub Desktop.
This file contains 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
$(document).ready(function(){ | |
persistence.store.websql.config(persistence, 'persistencetest', 'My db', 5 * 1024 * 1024); | |
var Project = persistence.define('Project', { | |
name: "TEXT" | |
}); | |
var Task = persistence.define('Task', { | |
name: "TEXT", | |
done: "BOOL" | |
}); | |
Project.hasMany('tasks', Task, 'project'); | |
Task.enableSync('/taskUpdates'); | |
Project.enableSync('/projectUpdates'); | |
module("Sync"); | |
function noConflictsHandler(conflicts, updatesToPush, callback) { | |
ok(false, "Should not go to conflict resolving"); | |
console.log("Conflicts: ", conflicts); | |
callback(); | |
} | |
asyncTest("creating some new objects", function() { | |
var p = new Project({name: "Locally created project"}); | |
persistence.add(p); | |
for(var i = 0; i < 10; i++) { | |
var t = new Task({name: "Local task " + i}); | |
p.tasks.add(t); | |
} | |
persistence.flush(function() { | |
ok(true, "project and tasks added locally"); | |
Task.syncAll(noConflictsHandler, function() { | |
ok(true, "returned from task sync"); | |
start(); | |
}); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment