@@ -31,104 +31,8 @@ describe('Zone', function () {
3131
3232 expect ( errorSpy ) . toHaveBeenCalled ( ) ;
3333 } ) ;
34-
35-
36- it ( 'should allow you to override alert/prompt/confirm' , function ( ) {
37- var alertSpy = jasmine . createSpy ( 'alert' ) ;
38- var promptSpy = jasmine . createSpy ( 'prompt' ) ;
39- var confirmSpy = jasmine . createSpy ( 'confirm' ) ;
40- var spies = {
41- 'alert' : alertSpy ,
42- 'prompt' : promptSpy ,
43- 'confirm' : confirmSpy
44- } ;
45- var myZone = Zone . current . fork ( {
46- name : 'spy' ,
47- onInvoke : ( parentZoneDelegate : ZoneDelegate , currentZone : Zone , targetZone : Zone ,
48- callback : Function , applyThis : any , applyArgs : any [ ] , source : string ) : any =>
49- {
50- if ( source ) {
51- spies [ source ] . apply ( null , applyArgs ) ;
52- } else {
53- return parentZoneDelegate . invoke ( targetZone , callback , applyThis , applyArgs , source ) ;
54- }
55- }
56- } ) ;
57-
58- myZone . run ( function ( ) {
59- alert ( 'alertMsg' ) ;
60- prompt ( 'promptMsg' , 'default' ) ;
61- confirm ( 'confirmMsg' ) ;
62- } ) ;
63-
64- expect ( alertSpy ) . toHaveBeenCalledWith ( 'alertMsg' ) ;
65- expect ( promptSpy ) . toHaveBeenCalledWith ( 'promptMsg' , 'default' ) ;
66- expect ( confirmSpy ) . toHaveBeenCalledWith ( 'confirmMsg' ) ;
67- } ) ;
68-
69- describe ( 'eventListener hooks' , function ( ) {
70- var button ;
71- var clickEvent ;
72-
73- beforeEach ( function ( ) {
74- button = document . createElement ( 'button' ) ;
75- clickEvent = document . createEvent ( 'Event' ) ;
76- clickEvent . initEvent ( 'click' , true , true ) ;
77- document . body . appendChild ( button ) ;
78- } ) ;
79-
80- afterEach ( function ( ) {
81- document . body . removeChild ( button ) ;
82- } ) ;
83-
84- it ( 'should support addEventListener' , function ( ) {
85- var hookSpy = jasmine . createSpy ( 'hook' ) ;
86- var eventListenerSpy = jasmine . createSpy ( 'eventListener' ) ;
87- var zone = rootZone . fork ( {
88- name : 'spy' ,
89- onScheduleTask : ( parentZoneDelegate : ZoneDelegate , currentZone : Zone , targetZone : Zone ,
90- task : Task ) : any => {
91- hookSpy ( ) ;
92- return parentZoneDelegate . scheduleTask ( targetZone , task ) ;
93- }
94- } ) ;
95-
96- zone . run ( function ( ) {
97- button . addEventListener ( 'click' , eventListenerSpy ) ;
98- } ) ;
99-
100- button . dispatchEvent ( clickEvent ) ;
101-
102- expect ( hookSpy ) . toHaveBeenCalled ( ) ;
103- expect ( eventListenerSpy ) . toHaveBeenCalled ( ) ;
104- } ) ;
105-
106- it ( 'should support removeEventListener' , function ( ) {
107- var hookSpy = jasmine . createSpy ( 'hook' ) ;
108- var eventListenerSpy = jasmine . createSpy ( 'eventListener' ) ;
109- var zone = rootZone . fork ( {
110- name : 'spy' ,
111- onCancelTask : ( parentZoneDelegate : ZoneDelegate , currentZone : Zone , targetZone : Zone ,
112- task : Task ) : any => {
113- hookSpy ( ) ;
114- return parentZoneDelegate . cancelTask ( targetZone , task ) ;
115- }
116- } ) ;
117-
118- zone . run ( function ( ) {
119- button . addEventListener ( 'click' , eventListenerSpy ) ;
120- button . removeEventListener ( 'click' , eventListenerSpy ) ;
121- } ) ;
122-
123- button . dispatchEvent ( clickEvent ) ;
124-
125- expect ( hookSpy ) . toHaveBeenCalled ( ) ;
126- expect ( eventListenerSpy ) . not . toHaveBeenCalled ( ) ;
127- } ) ;
128- } ) ;
12934 } ) ;
13035
131-
13236 it ( 'should allow zones to be run from within another zone' , function ( ) {
13337 var zoneA = Zone . current . fork ( { name : 'A' } ) ;
13438 var zoneB = Zone . current . fork ( { name : 'B' } ) ;
0 commit comments