Created
October 6, 2010 17:43
-
-
Save knowuh/613756 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
test("dragon updates work in rails", function() { | |
var dragons = Geniverse.store.find(Geniverse.DRAGONS_QUERY); | |
statusEquals(dragons, SC.Record.BUSY_LOADING, 'Activities should be loading'); | |
var newName = rndChars(20); | |
var dragon = null; | |
statusQueue([ | |
{ | |
target: dragons, | |
callback: function(){ | |
statusEquals(dragons, SC.Record.READY_CLEAN, "Next state was clean"); | |
ok(dragons.get('length') > 0, 'we should have at least one dragon after the dragons become "clean"'); | |
dragon = dragons.objectAt(0); | |
dragon.set('name', newName); | |
statusEquals(dragon, SC.Record.READY_DIRTY, "Dragon should be dirty after we update a field"); | |
Geniverse.store.commitRecords(); | |
statusQueue([ | |
{ | |
target: dragon, | |
callback: function() { | |
statusEquals(dragon, SC.Record.BUSY_COMMITTING, "Dragon should be busy committing while synchronizing"); | |
} | |
}, | |
// this causes an error message to pop-up in test runner: | |
//{ | |
//target: dragon, | |
//callback: function() { | |
//statusEquals(dragon, SC.Record.READY_CLEAN, "Dragon should be ready when synchronized"); | |
//} | |
//} | |
]); | |
} | |
}]); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It seems like nested statusQueue call backs is discouraged, but I needed to ensure that the datastore was loaded, so that I could get a reference to the first 'dragon'. Passing dragon into the array of statusQueue was resulting in error messages like cant call observe on null. (presumably because dragon was null at time of evaluation).
So nesting worked first the first item in the next statusQueue. But failed miserably in the second, with a pop-up error window in test-runner.