PageRenderTime 924ms CodeModel.GetById 915ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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