Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:Flotype/now-tests

Conflicts:
	client/public/index.html
	client/public/spec/RemoteSpec.js
	client/public/spec/ScopeSpec.js
	client/public/spec/VariableSpec.js
	client/testserver.js
	clusterclient/public/index.html
	clusterclient/public/now.html
	clusterclient/public/spec/ScopeSpec.js
	clusterclient/public/spec/VariableSpec.js
	clusterclient/slave.js
	clusterclient/testserver.js
  • Loading branch information...
commit 4bca5e03eb0a84d864220c275023bb81914eeb9a 2 parents d35c4f0 + 877dba8
@sridatta sridatta authored
View
1  client/public/index.html
@@ -12,6 +12,7 @@
<script type="text/javascript" src="spec/SpecHelper.js"></script>
<!-- include spec files here... -->
+ <script type="text/javascript" src="spec/ExcludeSpec.js"></script>
<script type="text/javascript" src="spec/RemoteSpec.js"></script>
<script type="text/javascript" src="spec/ScopeSpec.js"></script>
<script type="text/javascript" src="spec/VariableSpec.js"></script>
View
69 client/public/spec/ExcludeSpec.js
@@ -0,0 +1,69 @@
+xdescribe("Exclude tests", function() {
+
+ it("can exclude users from groups", function() {
+ var window2;
+
+ var group = SpecHelper.generateRandomString();
+
+ runs(function(){
+ window2 = SpecHelper.generateIFrame('now.html');
+ });
+
+ waits(500);
+
+
+ var nowReady = false;
+
+ runs(function(){
+ window2.now.ready(function(){
+ nowReady = true;
+ });
+ });
+
+ waitsFor(function(){
+ return nowReady;
+ }, "now to be ready", 2000);
+
+ runs(function(){
+ window2.now.joinGroup(group);
+ now.joinGroup(group);
+ now.eval("nowjs.getGroup('"+group+"').now.x = 1");
+ });
+
+ waitsFor(function(){
+ return now.x === 1 && window2.now.x === 1;
+ }, "both now window to receive group rv", 2000);
+
+
+ runs(function(){
+ now.eval("nowjs.getGroup('"+group+"').exclude('"+window2.now.core.clientId+"').now.x = 2");
+ });
+
+ waits(1000);
+
+ waitsFor(function(){
+ return now.x === 2 && window2.now.x === 1;
+ }, "exclude to prevent one window from receiving rv", 2000);
+
+ runs(function(){
+ now.eval("nowjs.getGroup('"+group+"').now.x = 4");
+
+ now.eval("nowjs.getGroup('"+group+"').exclude(['"+now.core.clientId+"']).now.x = 3");
+
+ });
+
+ waits(1000);
+
+ waitsFor(function(){
+ return now.x === 4 && window2.now.x === 3;
+ }, "exclude to prevent one window from receiving rv", 2000);
+
+ runs(function(){
+ expect(window2.now.x).toEqual(3);
+ });
+
+
+ });
+
+
+});
View
2  client/public/spec/RemoteSpec.js
@@ -1,4 +1,4 @@
-describe("Remote function calls", function() {
+xdescribe("Remote function calls", function() {
it("can call a remote function", function() {
View
2  client/public/spec/ScopeSpec.js
@@ -1,4 +1,4 @@
-describe("Server scoping tests", function() {
+xdescribe("Server scoping tests", function() {
it("adds to the defaultScope so new users get properties set in the `everyone.now` object", function() {
var window2;
View
100 client/public/spec/VariableSpec.js
@@ -1,6 +1,6 @@
describe("Variable Sync", function() {
- it("can sync primitives from client to server", function() {
+ xit("can sync primitives from client to server", function() {
function setIfEqual(k, v) {
equals = val === v && key === k;
@@ -49,13 +49,71 @@ describe("Variable Sync", function() {
});
+ it("can create terminal non-leaf nodes and do something with later ", function() {
+
+ var key = SpecHelper.generateRandomString();
+ var key2 = SpecHelper.generateRandomString();
+
+ var equals = false;
- it("can sync complicated objects from client to server", function() {
+ now.eval("this.now['"+key+"'] = {a: 1, b: []}");
- function setIfEqual(k, v){
+ waits(1000);
- equals = key === k && SpecHelper.deepEqual(v, val);
+ runs(function(){
+ expect(now[key].b.length).toEqual(0);
+
+ now.eval("this.now['"+key+"'].b.push(1)");
+ now.eval("this.now['"+key+"'].b[1] = 2");
+
+ });
+
+ waits(1000);
+
+
+ runs(function(){
+ expect(now[key].b[0]).toEqual(1);
+ expect(now[key].b[1]).toEqual(2);
+ expect(now[key].b.length).toEqual(2);
+
+ now[key2] = {a: 1, b: []};
+
+ now.variableCheck(key2, function(k, v) {
+ console.log(arguments);
+ equals = v.b.length === 0;
+ });
+ });
+
+ waitsFor(function(){
+ return equals;
+ }, "server to confirm array set", 2000);
+
+ runs(function(){
+
+ equals = false;
+
+ now[key2].b.push(1);
+ now[key2].b[1] = 2;
+ now.variableCheck(key2, function(k, v) {
+ equals = v.b[0] === 1 && v.b[1] === 2 && v.b.length === 2;
+ });
+
+ });
+
+ waitsFor(function(){
+ return equals;
+ }, "server to confirm array changes were set", 2000);
+
+
+
+
+ });
+
+ xit("can sync complicated objects from client to server", function() {
+
+ function setIfEqual(k, v){
+ equals = key === k && SpecHelper.deepEqual(v, val);
}
var key = SpecHelper.generateRandomString();
@@ -139,7 +197,39 @@ describe("Variable Sync", function() {
});
- it("can sync complicated arrays from client to server", function() {
+ xit("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();
+ });
+ });
+
+ xit("can sync complicated arrays from client to server", function() {
function setIfEqual(k, v){
equals = key === k && SpecHelper.deepEqual(v, val);
View
2  client/testserver.js
@@ -49,4 +49,4 @@ everyone.now.joinGroup = function(group) {
nowjs.getGroup(group).addUser(this.user.clientId);
}
-server.listen(8080)
+server.listen(80)
View
32 clusterclient/public/spec/VariableSpec.js
@@ -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){
Please sign in to comment.
Something went wrong with that request. Please try again.