1
1
// shim all the things
2
2
require ( 'core-js/es5' )
3
3
global . JSON = require ( 'json3' )
4
- const sinon = require ( 'sinon' )
5
- const assert = require ( 'assert' )
4
+ var sinon = require ( 'sinon' )
5
+ var assert = require ( 'assert' )
6
6
7
- const ClientKarma = require ( '../../client/karma' )
8
- const ContextKarma = require ( '../../context/karma' )
9
- const MockSocket = require ( './mocks' ) . Socket
7
+ var ClientKarma = require ( '../../client/karma' )
8
+ var ContextKarma = require ( '../../context/karma' )
9
+ var MockSocket = require ( './mocks' ) . Socket
10
10
11
11
describe ( 'Karma' , function ( ) {
12
- let socket , k , ck , windowNavigator , windowLocation , windowStub , startSpy , iframe , clientWindow
12
+ var socket , k , ck , windowNavigator , windowLocation , windowStub , startSpy , iframe , clientWindow
13
13
14
14
function setTransportTo ( transportName ) {
15
15
socket . _setTransportNameTo ( transportName )
@@ -33,7 +33,7 @@ describe('Karma', function () {
33
33
} )
34
34
35
35
it ( 'should start execution when all files loaded and pass config' , function ( ) {
36
- const config = ck . config = {
36
+ var config = ck . config = {
37
37
useIframe : true
38
38
}
39
39
@@ -45,7 +45,7 @@ describe('Karma', function () {
45
45
} )
46
46
47
47
it ( 'should open a new window when useIFrame is false' , function ( ) {
48
- const config = ck . config = {
48
+ var config = ck . config = {
49
49
useIframe : false ,
50
50
runInParent : false
51
51
}
@@ -85,13 +85,13 @@ describe('Karma', function () {
85
85
} )
86
86
87
87
it ( 'should not set up context if there was an error' , function ( ) {
88
- const config = ck . config = {
88
+ var config = ck . config = {
89
89
clearContext : true
90
90
}
91
91
92
92
socket . emit ( 'execute' , config )
93
93
94
- const mockWindow = { }
94
+ var mockWindow = { }
95
95
96
96
ck . error ( 'page reload' )
97
97
ck . setupContext ( mockWindow )
@@ -101,13 +101,13 @@ describe('Karma', function () {
101
101
} )
102
102
103
103
it ( 'should setup context if there was error but clearContext config is false' , function ( ) {
104
- const config = ck . config = {
104
+ var config = ck . config = {
105
105
clearContext : false
106
106
}
107
107
108
108
socket . emit ( 'execute' , config )
109
109
110
- const mockWindow = { }
110
+ var mockWindow = { }
111
111
112
112
ck . error ( 'page reload' )
113
113
ck . setupContext ( mockWindow )
@@ -118,11 +118,11 @@ describe('Karma', function () {
118
118
119
119
it ( 'should error out if a script attempted to reload the browser after setup' , function ( ) {
120
120
// Perform setup
121
- const config = ck . config = {
121
+ var config = ck . config = {
122
122
clearContext : true
123
123
}
124
124
socket . emit ( 'execute' , config )
125
- const mockWindow = { }
125
+ var mockWindow = { }
126
126
ck . setupContext ( mockWindow )
127
127
128
128
// Spy on our error handler
@@ -136,7 +136,7 @@ describe('Karma', function () {
136
136
} )
137
137
138
138
it ( 'should report navigator name' , function ( ) {
139
- const spyInfo = sinon . spy ( function ( info ) {
139
+ var spyInfo = sinon . spy ( function ( info ) {
140
140
assert ( info . name === 'Fake browser name' )
141
141
} )
142
142
@@ -153,7 +153,7 @@ describe('Karma', function () {
153
153
socket = new MockSocket ( )
154
154
k = new ClientKarma ( socket , { } , windowStub , windowNavigator , windowLocation )
155
155
156
- const spyInfo = sinon . spy ( function ( info ) {
156
+ var spyInfo = sinon . spy ( function ( info ) {
157
157
assert ( info . id === '567' )
158
158
} )
159
159
@@ -165,13 +165,13 @@ describe('Karma', function () {
165
165
166
166
describe ( 'result' , function ( ) {
167
167
it ( 'should buffer results when polling' , function ( ) {
168
- const spyResult = sinon . stub ( )
168
+ var spyResult = sinon . stub ( )
169
169
socket . on ( 'result' , spyResult )
170
170
171
171
setTransportTo ( 'polling' )
172
172
173
173
// emit 49 results
174
- for ( let i = 1 ; i < 50 ; i ++ ) {
174
+ for ( var i = 1 ; i < 50 ; i ++ ) {
175
175
ck . result ( { id : i } )
176
176
}
177
177
@@ -183,13 +183,13 @@ describe('Karma', function () {
183
183
} )
184
184
185
185
it ( 'should buffer results when polling' , function ( ) {
186
- const spyResult = sinon . stub ( )
186
+ var spyResult = sinon . stub ( )
187
187
socket . on ( 'result' , spyResult )
188
188
189
189
setTransportTo ( 'polling' )
190
190
191
191
// emit 40 results
192
- for ( let i = 1 ; i <= 40 ; i ++ ) {
192
+ for ( var i = 1 ; i <= 40 ; i ++ ) {
193
193
ck . result ( { id : i } )
194
194
}
195
195
@@ -199,7 +199,7 @@ describe('Karma', function () {
199
199
} )
200
200
201
201
it ( 'should emit "start" with total specs count first' , function ( ) {
202
- const log = [ ]
202
+ var log = [ ]
203
203
204
204
socket . on ( 'result' , function ( ) {
205
205
log . push ( 'result' )
@@ -217,13 +217,13 @@ describe('Karma', function () {
217
217
} )
218
218
219
219
it ( 'should not emit "start" if already done by the adapter' , function ( ) {
220
- const log = [ ]
220
+ var log = [ ]
221
221
222
- const spyStart = sinon . spy ( function ( ) {
222
+ var spyStart = sinon . spy ( function ( ) {
223
223
log . push ( 'start' )
224
224
} )
225
225
226
- const spyResult = sinon . spy ( function ( ) {
226
+ var spyResult = sinon . spy ( function ( ) {
227
227
log . push ( 'result' )
228
228
} )
229
229
@@ -243,7 +243,7 @@ describe('Karma', function () {
243
243
it ( 'should capture alert' , function ( ) {
244
244
sinon . spy ( ck , 'log' )
245
245
246
- const mockWindow = {
246
+ var mockWindow = {
247
247
alert : function ( ) {
248
248
throw new Error ( 'Alert was not patched!' )
249
249
}
@@ -256,43 +256,43 @@ describe('Karma', function () {
256
256
257
257
it ( 'should capture confirm' , function ( ) {
258
258
sinon . spy ( ck , 'log' )
259
- let confirmCalled = false
259
+ var confirmCalled = false
260
260
261
- const mockWindow = {
261
+ var mockWindow = {
262
262
confirm : function ( ) {
263
263
confirmCalled = true
264
264
return true
265
265
}
266
266
}
267
267
268
268
ck . setupContext ( mockWindow )
269
- const confirmResult = mockWindow . confirm ( 'What?' )
269
+ var confirmResult = mockWindow . confirm ( 'What?' )
270
270
assert ( ck . log . calledWith ( 'confirm' , [ 'What?' ] ) )
271
271
assert . equal ( confirmCalled , true )
272
272
assert . equal ( confirmResult , true )
273
273
} )
274
274
275
275
it ( 'should capture prompt' , function ( ) {
276
276
sinon . spy ( ck , 'log' )
277
- let promptCalled = false
277
+ var promptCalled = false
278
278
279
- const mockWindow = {
279
+ var mockWindow = {
280
280
prompt : function ( ) {
281
281
promptCalled = true
282
282
return 'user-input'
283
283
}
284
284
}
285
285
286
286
ck . setupContext ( mockWindow )
287
- const promptResult = mockWindow . prompt ( 'What is your favorite color?' , 'blue' )
287
+ var promptResult = mockWindow . prompt ( 'What is your favorite color?' , 'blue' )
288
288
assert ( ck . log . calledWith ( 'prompt' , [ 'What is your favorite color?' , 'blue' ] ) )
289
289
assert . equal ( promptCalled , true )
290
290
assert . equal ( promptResult , 'user-input' )
291
291
} )
292
292
} )
293
293
294
294
describe ( 'complete' , function ( ) {
295
- let clock
295
+ var clock
296
296
297
297
before ( function ( ) {
298
298
clock = sinon . useFakeTimers ( )
@@ -303,13 +303,13 @@ describe('Karma', function () {
303
303
} )
304
304
305
305
it ( 'should clean the result buffer before completing' , function ( ) {
306
- const spyResult = sinon . stub ( )
306
+ var spyResult = sinon . stub ( )
307
307
socket . on ( 'result' , spyResult )
308
308
309
309
setTransportTo ( 'polling' )
310
310
311
311
// emit 40 results
312
- for ( let i = 0 ; i < 40 ; i ++ ) {
312
+ for ( var i = 0 ; i < 40 ; i ++ ) {
313
313
ck . result ( { id : i } )
314
314
}
315
315
@@ -347,7 +347,7 @@ describe('Karma', function () {
347
347
sinon . spy ( ck , 'log' )
348
348
ck . config . captureConsole = true
349
349
350
- const mockWindow = {
350
+ var mockWindow = {
351
351
console : {
352
352
log : function ( ) { }
353
353
}
@@ -363,7 +363,7 @@ describe('Karma', function () {
363
363
sinon . spy ( ck , 'log' )
364
364
ck . config . captureConsole = false
365
365
366
- const mockWindow = {
366
+ var mockWindow = {
367
367
console : {
368
368
log : function ( ) { }
369
369
}
@@ -375,12 +375,12 @@ describe('Karma', function () {
375
375
} )
376
376
377
377
it ( 'should clear context window upon complete when clearContext config is true' , function ( ) {
378
- const config = ck . config = {
378
+ var config = ck . config = {
379
379
clearContext : true
380
380
}
381
381
382
382
socket . emit ( 'execute' , config )
383
- const CURRENT_URL = iframe . src
383
+ var CURRENT_URL = iframe . src
384
384
385
385
ck . complete ( )
386
386
@@ -392,12 +392,12 @@ describe('Karma', function () {
392
392
} )
393
393
394
394
it ( 'should not clear context window upon complete when clearContext config is false' , function ( ) {
395
- const config = ck . config = {
395
+ var config = ck . config = {
396
396
clearContext : false
397
397
}
398
398
399
399
socket . emit ( 'execute' , config )
400
- const CURRENT_URL = iframe . src
400
+ var CURRENT_URL = iframe . src
401
401
402
402
ck . complete ( )
403
403
0 commit comments