Permalink
Browse files

add removeGroupt est

  • Loading branch information...
1 parent 9247364 commit 1175a6ba9236096e818c76b19554266383a410b9 @ericz ericz committed Dec 25, 2011
Showing with 45 additions and 2 deletions.
  1. +21 −0 client/public/spec/ScopeSpec.js
  2. +24 −2 client/testserver.js
@@ -122,4 +122,25 @@ describe("Server scoping tests", function() {
expect(called).toBeTruthy();
});
});
+
+ it("removeGroup removes all users from group and triggers callback", function() {
+ var called = false;
+
+ var groupName = SpecHelper.generateRandomString();
+ var val = function(){
+ called = true;
+ };
+
+ now.removeGroupTest(groupName, val);
+
+ waitsFor(function(){
+ return called;
+ }, "generated callback to be called", 2000);
+
+ runs(function(){
+ expect(called).toBeTruthy();
+ });
+
+ });
+
});
View
@@ -36,6 +36,14 @@ everyone.now.multipleCallbacks = function(cb1, cb2) {
everyone.now.setEveryoneValue = function(key, val) {
everyone.now[key] = val;
+ console.log("*********", key, '=>', val);
+}
+
+everyone.now.test = function(key){
+ everyone.now['poop'] = key;
+ everyone.now[key] = 'doo';
+ eval('everyone.now["x"] = 3;');
+
}
everyone.now.setGroupValue = function(group, key, val) {
@@ -47,9 +55,23 @@ everyone.now.setValue = function(key, val){
}
everyone.now.eval = function(code){
+ console.log(code);
eval(code);
}
-everyone.now.joinGroup = function(group) {
- nowjs.getGroup(group).addUser(this.user.clientId);
+everyone.now.joinGroup = function(groupName, cb) {
+ var group = nowjs.getGroup(groupName);
+ group.addUser(this.user.clientId);
+}
+
+everyone.now.removeGroupTest = function(groupName, cb) {
+ var clientId = this.user.clientId;
+ var group = nowjs.getGroup(groupName);
+ group.addUser(clientId);
+ group.on('leave', function() {
+ if(this.user.clientId == clientId) {
+ cb();
+ }
+ });
+ nowjs.removeGroup(group);
}

0 comments on commit 1175a6b

Please sign in to comment.