@@ -28,6 +28,7 @@ describe('middleware.karma', () => {
28
28
karma : {
29
29
static : {
30
30
'client.html' : mocks . fs . file ( 0 , 'CLIENT HTML\n%X_UA_COMPATIBLE%%X_UA_COMPATIBLE_URL%' ) ,
31
+ 'client_with_context.html' : mocks . fs . file ( 0 , 'CLIENT_WITH_CONTEXT\n%SCRIPT_URL_ARRAY%' ) ,
31
32
'context.html' : mocks . fs . file ( 0 , 'CONTEXT\n%SCRIPTS%' ) ,
32
33
'debug.html' : mocks . fs . file ( 0 , 'DEBUG\n%SCRIPTS%\n%X_UA_COMPATIBLE%' ) ,
33
34
'karma.js' : mocks . fs . file ( 0 , 'root: %KARMA_URL_ROOT%, proxy: %KARMA_PROXY_PATH%, v: %KARMA_VERSION%' )
@@ -214,6 +215,21 @@ describe('middleware.karma', () => {
214
215
callHandlerWith ( '/__karma__/context.html' )
215
216
} )
216
217
218
+ it ( 'should serve context.html without using special patterns when replacing script tags' , ( done ) => {
219
+ includedFiles ( [
220
+ new MockFile ( '/.yarn/$$virtual/first.js' , 'sha123' ) ,
221
+ new MockFile ( '/.yarn/$$virtual/second.dart' , 'sha456' )
222
+ ] )
223
+
224
+ response . once ( 'end' , ( ) => {
225
+ expect ( nextSpy ) . not . to . have . been . called
226
+ expect ( response ) . to . beServedAs ( 200 , 'CONTEXT\n<script type="text/javascript" src="/__proxy__/__karma__/absolute/.yarn/$$virtual/first.js?sha123" crossorigin="anonymous"></script>\n<script type="text/javascript" src="/__proxy__/__karma__/absolute/.yarn/$$virtual/second.dart?sha456" crossorigin="anonymous"></script>' )
227
+ done ( )
228
+ } )
229
+
230
+ callHandlerWith ( '/__karma__/context.html' )
231
+ } )
232
+
217
233
it ( 'should serve context.html with replaced link tags' , ( done ) => {
218
234
includedFiles ( [
219
235
new MockFile ( '/first.css' , 'sha007' ) ,
@@ -373,6 +389,20 @@ describe('middleware.karma', () => {
373
389
callHandlerWith ( '/__karma__/context.html' )
374
390
} )
375
391
392
+ it ( 'should inline mappings without using special patterns' , ( done ) => {
393
+ fsMock . _touchFile ( '/karma/static/context.html' , 0 , '%MAPPINGS%' )
394
+ servedFiles ( [
395
+ new MockFile ( '/.yarn/$$virtual/abc/a.js' , 'sha_a' )
396
+ ] )
397
+
398
+ response . once ( 'end' , ( ) => {
399
+ expect ( response ) . to . beServedAs ( 200 , "window.__karma__.files = {\n '/__proxy__/__karma__/absolute/.yarn/$$virtual/abc/a.js': 'sha_a'\n};\n" )
400
+ done ( )
401
+ } )
402
+
403
+ callHandlerWith ( '/__karma__/context.html' )
404
+ } )
405
+
376
406
it ( 'should escape quotes in mappings with all served files' , ( done ) => {
377
407
fsMock . _touchFile ( '/karma/static/context.html' , 0 , '%MAPPINGS%' )
378
408
servedFiles ( [
@@ -490,4 +520,19 @@ describe('middleware.karma', () => {
490
520
491
521
callHandlerWith ( '/__karma__/debug.html' )
492
522
} )
523
+
524
+ it ( 'should serve client_with_context.html without using special patterns when replacing script urls' , ( done ) => {
525
+ includedFiles ( [
526
+ new MockFile ( '/.yarn/$$virtual/first.js' , 'sha123' ) ,
527
+ new MockFile ( '/.yarn/$$virtual/second.dart' , 'sha456' )
528
+ ] )
529
+
530
+ response . once ( 'end' , ( ) => {
531
+ expect ( nextSpy ) . not . to . have . been . called
532
+ expect ( response ) . to . beServedAs ( 200 , 'CLIENT_WITH_CONTEXT\nwindow.__karma__.scriptUrls = ["\\\\x3Cscript type=\\"text/javascript\\" src=\\"/__proxy__/__karma__/absolute/.yarn/$$virtual/first.js\\" crossorigin=\\"anonymous\\"\\\\x3E\\\\x3C/script\\\\x3E","\\\\x3Cscript type=\\"text/javascript\\" src=\\"/__proxy__/__karma__/absolute/.yarn/$$virtual/second.dart\\" crossorigin=\\"anonymous\\"\\\\x3E\\\\x3C/script\\\\x3E"];\n' )
533
+ done ( )
534
+ } )
535
+
536
+ callHandlerWith ( '/__karma__/client_with_context.html' )
537
+ } )
493
538
} )
0 commit comments