@@ -9,6 +9,10 @@ describe 'middleware.karma', ->
9
9
File = require (' ../../../lib/file-list' ).File
10
10
Url = require (' ../../../lib/file-list' ).Url
11
11
12
+ MockFile = (path , sha ) ->
13
+ File .call @ , path
14
+ @sha = sha or ' sha-default'
15
+
12
16
fsMock = mocks .fs .create
13
17
karma :
14
18
static :
@@ -101,61 +105,61 @@ describe 'middleware.karma', ->
101
105
102
106
it ' should serve context.html with replaced script tags' , (done ) ->
103
107
includedFiles [
104
- new File (' /first.js' , new Date 12345 )
105
- new File (' /second.dart' , new Date 67890 )
108
+ new MockFile (' /first.js' , ' sha123 ' )
109
+ new MockFile (' /second.dart' , ' sha456 ' )
106
110
]
107
111
108
112
response .once ' end' , ->
109
113
expect (nextSpy).not .to .have .been .called
110
114
expect (response).to .beServedAs 200 , ' CONTEXT\n ' +
111
- ' <script type="text/javascript" src="/absolute/first.js?12345 "></script>\n ' +
112
- ' <script type="application/dart" src="/absolute/second.dart?67890 "></script>'
115
+ ' <script type="text/javascript" src="/absolute/first.js?sha123 "></script>\n ' +
116
+ ' <script type="application/dart" src="/absolute/second.dart?sha456 "></script>'
113
117
done ()
114
118
115
119
callHandlerWith ' /__karma__/context.html'
116
120
117
121
118
122
it ' should serve context.html with replaced link tags' , (done ) ->
119
123
includedFiles [
120
- new File (' /first.css' , new Date 12345 )
124
+ new MockFile (' /first.css' , ' sha007 ' )
121
125
]
122
126
123
127
response .once ' end' , ->
124
128
expect (nextSpy).not .to .have .been .called
125
129
expect (response).to .beServedAs 200 , ' CONTEXT\n ' +
126
- ' <link type="text/css" href="/absolute/first.css?12345 " rel="stylesheet">'
130
+ ' <link type="text/css" href="/absolute/first.css?sha007 " rel="stylesheet">'
127
131
done ()
128
132
129
133
callHandlerWith ' /__karma__/context.html'
130
134
131
135
132
136
it ' should serve context.html with the correct path for the script tags' , (done ) ->
133
137
includedFiles [
134
- new File (' /some/abc/a.js' , new Date 12345 )
135
- new File (' /base/path/b.js' , new Date 67890 )
138
+ new MockFile (' /some/abc/a.js' , ' sha ' )
139
+ new MockFile (' /base/path/b.js' , ' shaaa ' )
136
140
]
137
141
138
142
response .once ' end' , ->
139
143
expect (nextSpy).not .to .have .been .called
140
144
expect (response).to .beServedAs 200 , ' CONTEXT\n ' +
141
- ' <script type="text/javascript" src="/absolute/some/abc/a.js?12345 "></script>\n ' +
142
- ' <script type="text/javascript" src="/base/b.js?67890 "></script>'
145
+ ' <script type="text/javascript" src="/absolute/some/abc/a.js?sha "></script>\n ' +
146
+ ' <script type="text/javascript" src="/base/b.js?shaaa "></script>'
143
147
done ()
144
148
145
149
callHandlerWith ' /__karma__/context.html'
146
150
147
151
148
152
it ' should serve context.html with the correct path for link tags' , (done ) ->
149
153
includedFiles [
150
- new File (' /some/abc/a.css' , new Date 12345 )
151
- new File (' /base/path/b.css' , new Date 67890 )
154
+ new MockFile (' /some/abc/a.css' , ' sha1 ' )
155
+ new MockFile (' /base/path/b.css' , ' sha2 ' )
152
156
]
153
157
154
158
response .once ' end' , ->
155
159
expect (nextSpy).not .to .have .been .called
156
160
expect (response).to .beServedAs 200 , ' CONTEXT\n ' +
157
- ' <link type="text/css" href="/absolute/some/abc/a.css?12345 " rel="stylesheet">\n ' +
158
- ' <link type="text/css" href="/base/b.css?67890 " rel="stylesheet">'
161
+ ' <link type="text/css" href="/absolute/some/abc/a.css?sha1 " rel="stylesheet">\n ' +
162
+ ' <link type="text/css" href="/base/b.css?sha2 " rel="stylesheet">'
159
163
done ()
160
164
161
165
callHandlerWith ' /__karma__/context.html'
@@ -193,14 +197,14 @@ describe 'middleware.karma', ->
193
197
it ' should inline mappings with all served files' , (done ) ->
194
198
fsMock ._touchFile ' /karma/static/context.html' , 0 , ' %MAPPINGS%'
195
199
servedFiles [
196
- new File (' /some/abc/a.js' , new Date 12345 )
197
- new File (' /base/path/b.js' , new Date 67890 )
200
+ new MockFile (' /some/abc/a.js' , ' sha_a ' )
201
+ new MockFile (' /base/path/b.js' , ' sha_b ' )
198
202
]
199
203
200
204
response .once ' end' , ->
201
205
expect (response).to .beServedAs 200 , ' window.__karma__.files = {\n ' +
202
- " '/absolute/some/abc/a.js': '12345 ',\n " +
203
- " '/base/b.js': '67890 '\n " +
206
+ " '/absolute/some/abc/a.js': 'sha_a ',\n " +
207
+ " '/base/b.js': 'sha_b '\n " +
204
208
" };\n "
205
209
done ()
206
210
@@ -209,8 +213,8 @@ describe 'middleware.karma', ->
209
213
210
214
it ' should serve debug.html with replaced script tags without timestamps' , (done ) ->
211
215
includedFiles [
212
- new File (' /first.js' , new Date 12345 )
213
- new File (' /base/path/b.js' , new Date 67890 )
216
+ new MockFile (' /first.js' )
217
+ new MockFile (' /base/path/b.js' )
214
218
]
215
219
216
220
response .once ' end' , ->
@@ -225,8 +229,8 @@ describe 'middleware.karma', ->
225
229
226
230
it ' should serve debug.html with replaced link tags without timestamps' , (done ) ->
227
231
includedFiles [
228
- new File (' /first.css' , new Date 12345 )
229
- new File (' /base/path/b.css' , new Date 67890 )
232
+ new MockFile (' /first.css' )
233
+ new MockFile (' /base/path/b.css' )
230
234
]
231
235
232
236
response .once ' end' , ->
0 commit comments