Skip to content

Commit

Permalink
added additonal deep object test
Browse files Browse the repository at this point in the history
  • Loading branch information
ericz committed Jul 20, 2011
1 parent c176a34 commit 19e8857
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 2 deletions.
34 changes: 32 additions & 2 deletions client/public/spec/VariableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ describe("Variable Sync", function() {
it("can sync complicated objects from client to server", function() {

function setIfEqual(k, v){

equals = key === k && SpecHelper.deepEqual(v, val);

}

var key = SpecHelper.generateRandomString();
Expand Down Expand Up @@ -139,6 +137,38 @@ describe("Variable Sync", function() {

});

it("can handle deep objects synced from server and watch along the path", function(){


function setIfEqual(k, v){
return equals = key === k && SpecHelper.deepEqual(v, val);
}

var key = SpecHelper.generateRandomString();
var val = {a: 1, b: {c: 1, d: {e: 1}}};

now.setValue(key, val);

// Call server function to check if value synced
var equals;

waitsFor(function(){
return setIfEqual(key, now[key]);
}, "server to confirm object was set", 5000);

runs(function(){
now[key]['b']['c'] = 6;
});

runs(function(){
now.variableCheck(key, setIfEqual);
});

runs(function(){
expect(equals).toBeTruthy();
});
});

it("can sync complicated arrays from client to server", function() {

function setIfEqual(k, v){
Expand Down
32 changes: 32 additions & 0 deletions clusterclient/public/spec/VariableSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,38 @@ describe("Variable Sync", function() {

});

it("can handle deep objects synced from server and watch along the path", function(){


function setIfEqual(k, v){
return equals = key === k && SpecHelper.deepEqual(v, val);
}

var key = SpecHelper.generateRandomString();
var val = {a: 1, b: {c: 1, d: {e: 1}}};

now.setValue(key, val);

// Call server function to check if value synced
var equals;

waitsFor(function(){
return setIfEqual(key, now[key]);
}, "server to confirm object was set", 5000);

runs(function(){
now[key]['b']['c'] = 6;
});

runs(function(){
now.variableCheck(key, setIfEqual);
});

runs(function(){
expect(equals).toBeTruthy();
});
});

it("can sync complicated arrays from client to server", function() {

function setIfEqual(k, v){
Expand Down

0 comments on commit 19e8857

Please sign in to comment.