1+ // shim all the things
2+ require ( 'core-js/es5' )
3+ global . JSON = require ( 'json3' )
14var sinon = require ( 'sinon' )
2- var chai = require ( 'chai' )
3- chai . use ( require ( 'sinon-chai' ) )
4- var expect = chai . expect
5+ var assert = require ( 'assert' )
56
67var Karma = require ( '../../client/karma' )
78var MockSocket = require ( './mocks' ) . Socket
@@ -31,10 +32,10 @@ describe('Karma', function () {
3132 }
3233
3334 socket . emit ( 'execute' , config )
34- expect ( startSpy ) . to . not . have . been . called
35+ assert ( ! startSpy . called )
3536
3637 k . loaded ( )
37- expect ( startSpy ) . to . have . been . calledWith ( config )
38+ assert ( startSpy . calledWith ( config ) )
3839 } )
3940
4041 it ( 'should open a new window when useIFrame is false' , function ( ) {
@@ -43,24 +44,24 @@ describe('Karma', function () {
4344 }
4445
4546 socket . emit ( 'execute' , config )
46- expect ( k . start ) . to . not . have . been . called
47+ assert ( ! k . start . called )
4748
4849 k . loaded ( )
49- expect ( startSpy ) . to . have . been . calledWith ( config )
50- expect ( windowStub ) . to . have . been . calledWith ( 'about:blank' )
50+ assert ( startSpy . calledWith ( config ) )
51+ assert ( windowStub . calledWith ( 'about:blank' ) )
5152 } )
5253
5354 it ( 'should stop execution' , function ( ) {
5455 sinon . spy ( k , 'complete' )
5556 socket . emit ( 'stop' )
56- expect ( k . complete ) . to . have . been . called
57+ assert ( k . complete . called )
5758 } )
5859
5960 it ( 'should not start execution if any error during loading files' , function ( ) {
6061 k . error ( 'syntax error' , '/some/file.js' , 11 )
6162 k . loaded ( )
6263 sinon . spy ( k , 'start' )
63- expect ( startSpy ) . to . not . have . been . called
64+ assert ( ! startSpy . called )
6465 } )
6566
6667 it ( 'should remove reference to start even after syntax error' , function ( ) {
@@ -69,11 +70,11 @@ describe('Karma', function () {
6970 k . start = ADAPTER_START_FN
7071 k . error ( 'syntax error' , '/some/file.js' , 11 )
7172 k . loaded ( )
72- expect ( k . start ) . to . not . be . eql ( ADAPTER_START_FN )
73+ assert . notEqual ( k . start , ADAPTER_START_FN )
7374
7475 k . start = ADAPTER_START_FN
7576 k . loaded ( )
76- expect ( k . start ) . to . not . be . eql ( ADAPTER_START_FN )
77+ assert . notEqual ( k . start , ADAPTER_START_FN )
7778 } )
7879
7980 it ( 'should not set up context if there was an error' , function ( ) {
@@ -88,9 +89,9 @@ describe('Karma', function () {
8889 k . error ( 'page reload' )
8990 k . setupContext ( mockWindow )
9091
91- expect ( mockWindow . __karma__ ) . to . not . exist
92- expect ( mockWindow . onbeforeunload ) . to . not . exist
93- expect ( mockWindow . onerror ) . to . not . exist
92+ assert ( mockWindow . __karma__ == null )
93+ assert ( mockWindow . onbeforeunloadK == null )
94+ assert ( mockWindow . onerror == null )
9495 } )
9596
9697 it ( 'should setup context if there was error but clearContext config is false' , function ( ) {
@@ -105,22 +106,22 @@ describe('Karma', function () {
105106 k . error ( 'page reload' )
106107 k . setupContext ( mockWindow )
107108
108- expect ( mockWindow . __karma__ ) . to . exist
109- expect ( mockWindow . onbeforeunload ) . to . exist
110- expect ( mockWindow . onerror ) . to . exist
109+ assert ( mockWindow . __karma__ != null )
110+ assert ( mockWindow . onbeforeunload != null )
111+ assert ( mockWindow . onerror != null )
111112 } )
112113
113114 it ( 'should report navigator name' , function ( ) {
114115 var spyInfo = sinon . spy ( function ( info ) {
115- expect ( info . name ) . to . be . eql ( 'Fake browser name' )
116+ assert ( info . name === 'Fake browser name' )
116117 } )
117118
118119 windowNavigator . userAgent = 'Fake browser name'
119120 windowLocation . search = ''
120121 socket . on ( 'register' , spyInfo )
121122 socket . emit ( 'connect' )
122123
123- expect ( spyInfo ) . to . have . been . called
124+ assert ( spyInfo . called )
124125 } )
125126
126127 it ( 'should report browser id' , function ( ) {
@@ -129,13 +130,13 @@ describe('Karma', function () {
129130 k = new Karma ( socket , { } , windowStub , windowNavigator , windowLocation )
130131
131132 var spyInfo = sinon . spy ( function ( info ) {
132- expect ( info . id ) . to . be . eql ( '567' )
133+ assert ( info . id === '567' )
133134 } )
134135
135136 socket . on ( 'register' , spyInfo )
136137 socket . emit ( 'connect' )
137138
138- expect ( spyInfo ) . to . have . been . called
139+ assert ( spyInfo . called )
139140 } )
140141
141142 describe ( 'result' , function ( ) {
@@ -150,11 +151,11 @@ describe('Karma', function () {
150151 k . result ( { id : i } )
151152 }
152153
153- expect ( spyResult ) . to . not . have . been . called
154+ assert ( ! spyResult . called )
154155
155156 k . result ( 'result' , { id : 50 } )
156- expect ( spyResult ) . to . have . been . called
157- expect ( spyResult . args [ 0 ] [ 0 ] . length ) . to . be . eql ( 50 )
157+ assert ( spyResult . called )
158+ assert ( spyResult . args [ 0 ] [ 0 ] . length === 50 )
158159 } )
159160
160161 it ( 'should buffer results when polling' , function ( ) {
@@ -169,8 +170,8 @@ describe('Karma', function () {
169170 }
170171
171172 k . complete ( )
172- expect ( spyResult ) . to . have . been . called
173- expect ( spyResult . args [ 0 ] [ 0 ] . length ) . to . be . eql ( 40 )
173+ assert ( spyResult . called )
174+ assert ( spyResult . args [ 0 ] [ 0 ] . length === 40 )
174175 } )
175176
176177 it ( 'should emit "start" with total specs count first' , function ( ) {
@@ -188,7 +189,7 @@ describe('Karma', function () {
188189
189190 // adapter didn't call info({total: x})
190191 k . result ( )
191- expect ( log ) . to . be . eql ( [ 'start' , 'result' ] )
192+ assert . deepEqual ( log , [ 'start' , 'result' ] )
192193 } )
193194
194195 it ( 'should not emit "start" if already done by the adapter' , function ( ) {
@@ -209,8 +210,8 @@ describe('Karma', function () {
209210
210211 k . info ( { total : 321 } )
211212 k . result ( )
212- expect ( log ) . to . be . eql ( [ 'start' , 'result' ] )
213- expect ( spyStart ) . to . have . been . calledWith ( { total : 321 } )
213+ assert . deepEqual ( log , [ 'start' , 'result' ] )
214+ assert ( spyStart . calledWith ( { total : 321 } ) )
214215 } )
215216 } )
216217
@@ -226,7 +227,7 @@ describe('Karma', function () {
226227
227228 k . setupContext ( mockWindow )
228229 mockWindow . alert ( 'What?' )
229- expect ( k . log ) . to . have . been . calledWith ( 'alert' , [ 'What?' ] )
230+ assert ( k . log . calledWith ( 'alert' , [ 'What?' ] ) )
230231 } )
231232 } )
232233
@@ -235,16 +236,16 @@ describe('Karma', function () {
235236 k . store ( 'a' , 10 )
236237 k . store ( 'b' , [ 1 , 2 , 3 ] )
237238
238- expect ( k . store ( 'a' ) ) . to . be . eql ( 10 )
239- expect ( k . store ( 'b' ) ) . to . be . eql ( [ 1 , 2 , 3 ] )
239+ assert . equal ( k . store ( 'a' ) , 10 )
240+ assert . deepEqual ( k . store ( 'b' ) , [ 1 , 2 , 3 ] )
240241 } )
241242
242243 it ( 'should clone arrays to avoid memory leaks' , function ( ) {
243244 var array = [ 1 , 2 , 3 , 4 , 5 ]
244245
245246 k . store ( 'one.array' , array )
246- expect ( k . store ( 'one.array' ) ) . to . be . eql ( array )
247- expect ( k . store ( 'one.array' ) ) . to . be . eql ( array )
247+ assert . deepEqual ( k . store ( 'one.array' ) , array )
248+ assert . deepEqual ( k . store ( 'one.array' ) , array )
248249 } )
249250 } )
250251
@@ -270,10 +271,10 @@ describe('Karma', function () {
270271 k . result ( { id : i } )
271272 }
272273
273- expect ( spyResult ) . to . not . have . been . called
274+ assert ( ! spyResult . called )
274275
275276 k . complete ( )
276- expect ( spyResult ) . to . have . been . called
277+ assert ( spyResult . called )
277278 } )
278279
279280 it ( 'should navigate the client to return_url if specified' , function ( done ) {
@@ -291,7 +292,7 @@ describe('Karma', function () {
291292
292293 clock . tick ( 500 )
293294 setTimeout ( function ( ) {
294- expect ( windowLocation . href ) . to . be . eql ( 'http://return.com' )
295+ assert ( windowLocation . href === 'http://return.com' )
295296 done ( )
296297 } , 5 )
297298 clock . tick ( 10 )
@@ -309,8 +310,8 @@ describe('Karma', function () {
309310
310311 k . setupContext ( mockWindow )
311312 mockWindow . console . log ( 'What?' )
312- expect ( k . log ) . to . have . been . calledWith ( 'log' )
313- expect ( k . log . args [ 0 ] [ 1 ] [ 0 ] ) . to . be . eql ( 'What?' )
313+ assert ( k . log . calledWith ( 'log' ) )
314+ assert ( k . log . args [ 0 ] [ 1 ] [ 0 ] === 'What?' )
314315 } )
315316
316317 it ( 'should not patch the console if captureConsole is false' , function ( ) {
@@ -325,7 +326,7 @@ describe('Karma', function () {
325326
326327 k . setupContext ( mockWindow )
327328 mockWindow . console . log ( 'hello' )
328- expect ( k . log ) . to . not . have . been . called
329+ assert ( ! k . log . called )
329330 } )
330331
331332 it ( 'should clear context window upon complete when clearContext config is true' , function ( ) {
@@ -338,9 +339,9 @@ describe('Karma', function () {
338339
339340 k . complete ( )
340341
341- clock . tick ( 1 )
342+ clock . tick ( 20 )
342343
343- expect ( iframe . src ) . to . not . be . eql ( CURRENT_URL )
344+ assert . notEqual ( iframe . src , CURRENT_URL )
344345 } )
345346
346347 it ( 'should not clear context window upon complete when clearContext config is false' , function ( ) {
@@ -355,7 +356,7 @@ describe('Karma', function () {
355356
356357 clock . tick ( 1 )
357358
358- expect ( iframe . src ) . to . be . eql ( CURRENT_URL )
359+ assert . equal ( iframe . src , CURRENT_URL )
359360 } )
360361 } )
361362} )
0 commit comments