@@ -44,31 +44,40 @@ describe('Karma', function () {
44
44
assert ( startSpy . calledWith ( config ) )
45
45
} )
46
46
47
- it ( 'should open a new window when useIFrame is false' , function ( ) {
47
+ it ( 'should open a new window when useIFrame is false' , function ( done ) {
48
48
var config = ck . config = {
49
49
useIframe : false ,
50
50
runInParent : false
51
51
}
52
52
53
53
socket . emit ( 'execute' , config )
54
- assert ( ! ck . start . called )
54
+ setTimeout ( function nextEventLoop ( ) {
55
+ assert ( ! ck . start . called )
55
56
56
- ck . loaded ( )
57
- assert ( startSpy . calledWith ( config ) )
58
- assert ( windowStub . calledWith ( 'context.html' ) )
57
+ ck . loaded ( )
58
+ assert ( startSpy . calledWith ( config ) )
59
+ assert ( windowStub . calledWith ( 'context.html' ) )
60
+ done ( )
61
+ } )
59
62
} )
60
63
61
- it ( 'should not set style on elements' , function ( ) {
64
+ it ( 'should not set style on elements' , function ( done ) {
62
65
var config = { }
63
66
socket . emit ( 'execute' , config )
64
- assert ( Object . keys ( elements [ 0 ] . style ) . length === 0 )
67
+ setTimeout ( function nextEventLoop ( ) {
68
+ assert ( Object . keys ( elements [ 0 ] . style ) . length === 0 )
69
+ done ( )
70
+ } )
65
71
} )
66
72
67
- it ( 'should set display none on elements if clientDisplayNone' , function ( ) {
73
+ it ( 'should set display none on elements if clientDisplayNone' , function ( done ) {
68
74
var config = { clientDisplayNone : true }
69
75
socket . emit ( 'execute' , config )
70
- assert ( elements [ 0 ] . style . display === 'none' )
71
- assert ( elements [ 1 ] . style . display === 'none' )
76
+ setTimeout ( function nextEventLoop ( ) {
77
+ assert ( elements [ 0 ] . style . display === 'none' )
78
+ assert ( elements [ 1 ] . style . display === 'none' )
79
+ done ( )
80
+ } )
72
81
} )
73
82
74
83
it ( 'should stop execution' , function ( ) {
@@ -97,55 +106,65 @@ describe('Karma', function () {
97
106
assert . notStrictEqual ( k . start , ADAPTER_START_FN )
98
107
} )
99
108
100
- it ( 'should not set up context if there was an error' , function ( ) {
109
+ it ( 'should not set up context if there was an error' , function ( done ) {
101
110
var config = ck . config = {
102
111
clearContext : true
103
112
}
104
113
105
114
socket . emit ( 'execute' , config )
106
115
107
- var mockWindow = { }
116
+ setTimeout ( function nextEventLoop ( ) {
117
+ var mockWindow = { }
108
118
109
- ck . error ( 'page reload' )
110
- ck . setupContext ( mockWindow )
119
+ ck . error ( 'page reload' )
120
+ ck . setupContext ( mockWindow )
111
121
112
- assert ( mockWindow . onbeforeunload == null )
113
- assert ( mockWindow . onerror == null )
122
+ assert ( mockWindow . onbeforeunload == null )
123
+ assert ( mockWindow . onerror == null )
124
+ done ( )
125
+ } )
114
126
} )
115
127
116
- it ( 'should setup context if there was error but clearContext config is false' , function ( ) {
128
+ it ( 'should setup context if there was error but clearContext config is false' , function ( done ) {
117
129
var config = ck . config = {
118
130
clearContext : false
119
131
}
120
132
121
133
socket . emit ( 'execute' , config )
122
134
123
- var mockWindow = { }
135
+ setTimeout ( function nextEventLoop ( ) {
136
+ var mockWindow = { }
124
137
125
- ck . error ( 'page reload' )
126
- ck . setupContext ( mockWindow )
138
+ ck . error ( 'page reload' )
139
+ ck . setupContext ( mockWindow )
127
140
128
- assert ( mockWindow . onbeforeunload != null )
129
- assert ( mockWindow . onerror != null )
141
+ assert ( mockWindow . onbeforeunload != null )
142
+ assert ( mockWindow . onerror != null )
143
+ done ( )
144
+ } )
130
145
} )
131
146
132
- it ( 'should error out if a script attempted to reload the browser after setup' , function ( ) {
147
+ it ( 'should error out if a script attempted to reload the browser after setup' , function ( done ) {
133
148
// Perform setup
134
149
var config = ck . config = {
135
150
clearContext : true
136
151
}
137
152
socket . emit ( 'execute' , config )
138
- var mockWindow = { }
139
- ck . setupContext ( mockWindow )
140
153
141
- // Spy on our error handler
142
- sinon . spy ( k , 'error' )
154
+ setTimeout ( function nextEventLoop ( ) {
155
+ var mockWindow = { }
156
+ ck . setupContext ( mockWindow )
157
+
158
+ // Spy on our error handler
159
+ sinon . spy ( k , 'error' )
143
160
144
- // Emulate an unload event
145
- mockWindow . onbeforeunload ( )
161
+ // Emulate an unload event
162
+ mockWindow . onbeforeunload ( )
146
163
147
- // Assert our spy was called
148
- assert ( k . error . calledWith ( 'Some of your tests did a full page reload!' ) )
164
+ // Assert our spy was called
165
+ assert ( k . error . calledWith ( 'Some of your tests did a full page reload!' ) )
166
+ done ( )
167
+ } )
149
168
} )
150
169
151
170
it ( 'should report navigator name' , function ( ) {
@@ -439,12 +458,10 @@ describe('Karma', function () {
439
458
}
440
459
441
460
socket . emit ( 'execute' , config )
461
+ clock . tick ( 1 )
442
462
var CURRENT_URL = iframe . src
443
-
444
463
ck . complete ( )
445
-
446
464
clock . tick ( 1 )
447
-
448
465
assert . strictEqual ( iframe . src , CURRENT_URL )
449
466
} )
450
467
@@ -455,6 +472,7 @@ describe('Karma', function () {
455
472
}
456
473
457
474
socket . emit ( 'execute' , config )
475
+ clock . tick ( 1 )
458
476
assert ( ! startSpy . called )
459
477
460
478
ck . loaded ( )
0 commit comments