Author: jmorliaguet
Date: Thu Feb  2 20:11:15 2006
New Revision: 2273

Modified:
   cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
Log:

- added tests for subscribers



Modified: 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html
==============================================================================
--- 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    (original)
+++ 
cpsskins/branches/jmo-perspectives/ui/framework/tests/unit/cpsskins_test.html   
    Thu Feb  2 20:11:15 2006
@@ -378,6 +378,47 @@
 
     }},
 
+    /* Events */
+
+    testSubscribe: function() { with(this) {
+      var info;
+      var handler1 = function(subscriber, context) {
+        info = {'subscriber': subscriber.id, 'context': context.id};
+      }
+
+      var obj1 = new Object({'id': 'object1'});
+      var context1 = new Object({'id': 'context1'});
+      var context2 = new Object({'id': 'context2'});
+
+      CPSSkins.registerEventHandler(obj1, 'event1', handler1);
+      CPSSkins.subscribe(obj1, 'event1');
+
+      assertEqual($H(info).inspect(), $H({}).inspect());
+
+      var info = null;
+      CPSSkins.notify(context1, 'event2');
+      assertEqual($H(info).inspect(), $H({}).inspect());
+
+      var info = null;
+      CPSSkins.notify(context1, 'event1');
+      assertEqual($H(info).inspect(),
+                  $H({"subscriber":"object1","context":"context1"}).inspect());
+
+      var info = null;
+      CPSSkins.notify(context2, 'event1');
+      assertEqual($H(info).inspect(),
+                  $H({"subscriber":"object1","context":"context2"}).inspect());
+
+      CPSSkins.unsubscribe(obj1, 'event1');
+
+      var info = null;
+      CPSSkins.notify(context1, 'event1');
+      assertEqual($H(info).inspect(), $H({}).inspect());
+
+    }},
+
+    /* Perspectives */
+
     testSwitchPerspectives: function() { with(this) {
       var p1 = $("p1").parentNode;
       var p1_2 = $("p1_2").parentNode;
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to