/tests/org/osflash/signals/GenericEventTest.as

http://github.com/robertpenner/as3-signals · ActionScript · 62 lines · 51 code · 11 blank · 0 comment · 0 complexity · b277bee6fbef0ed83cc95c9bf0643ecc MD5 · raw file

  1. package org.osflash.signals
  2. {
  3. import asunit.asserts.*;
  4. import org.osflash.signals.events.GenericEvent;
  5. import org.osflash.signals.events.IEvent;
  6. public class GenericEventTest
  7. {
  8. private var instance:GenericEvent;
  9. [Before]
  10. public function setUp():void
  11. {
  12. instance = new GenericEvent();
  13. }
  14. [After]
  15. public function tearDown():void
  16. {
  17. instance = null;
  18. }
  19. public function testInstantiated():void
  20. {
  21. assertTrue("GenericEvent instantiated", instance is GenericEvent);
  22. assertNull('target is null by default', instance.target);
  23. assertFalse('bubbles is false by default', instance.bubbles);
  24. }
  25. [Test]
  26. public function bubbles_roundtrips_through_constructor():void
  27. {
  28. var bubblingEvent:GenericEvent = new GenericEvent(true);
  29. assertTrue(bubblingEvent.bubbles);
  30. }
  31. [Test]
  32. public function clone_should_be_instance_of_original_event_class():void
  33. {
  34. var theClone:IEvent = instance.clone();
  35. assertTrue(theClone is GenericEvent);
  36. }
  37. [Test]
  38. public function clone_non_bubbling_event_should_have_bubbles_false():void
  39. {
  40. var theClone:GenericEvent = GenericEvent(instance.clone());
  41. assertFalse(theClone.bubbles);
  42. }
  43. [Test]
  44. public function clone_bubbling_event_should_have_bubbles_true():void
  45. {
  46. var bubblingEvent:GenericEvent = new GenericEvent(true);
  47. var theClone:IEvent = bubblingEvent.clone();
  48. assertTrue(theClone.bubbles);
  49. }
  50. }
  51. }