@@ -108,6 +108,17 @@ describe('JSON Pipe Test', () => {
108
108
'last-modified' : 'Wed, 12 Oct 2009 17:50:00 GMT' ,
109
109
} ,
110
110
} ) ,
111
+ )
112
+ . reply (
113
+ 'helix-content-bus' ,
114
+ 'foobar/live/en/index.json' ,
115
+ new PipelineResponse ( TEST_SINGLE_SHEET , {
116
+ headers : {
117
+ 'content-type' : 'application/json' ,
118
+ 'x-amz-meta-x-source-location' : 'foo-bar' ,
119
+ 'last-modified' : 'Wed, 12 Oct 2009 17:50:00 GMT' ,
120
+ } ,
121
+ } ) ,
111
122
) ,
112
123
timer : {
113
124
update : ( ) => { } ,
@@ -126,7 +137,23 @@ describe('JSON Pipe Test', () => {
126
137
127
138
it ( 'fetches correct content' , async ( ) => {
128
139
const state = createDefaultState ( ) ;
129
- const resp = await jsonPipe ( state , new PipelineRequest ( 'https://json-filter.com/?limit=10&offset=5' ) ) ;
140
+ let resp = await jsonPipe ( state , new PipelineRequest ( 'https://json-filter.com/?limit=10&offset=5' ) ) ;
141
+ assert . strictEqual ( resp . status , 200 ) ;
142
+ assert . deepStrictEqual ( await resp . json ( ) , {
143
+ ':type' : 'sheet' ,
144
+ offset : 5 ,
145
+ limit : 10 ,
146
+ total : TEST_DATA . length ,
147
+ data : TEST_DATA . slice ( 5 , 15 ) ,
148
+ } ) ;
149
+ assert . deepStrictEqual ( Object . fromEntries ( resp . headers . entries ( ) ) , {
150
+ 'content-type' : 'application/json' ,
151
+ 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar p_Atrz_qDg26DmSe9a p_foobar' ,
152
+ 'last-modified' : 'Wed, 12 Oct 2009 17:50:00 GMT' ,
153
+ } ) ;
154
+ // live (code coverage)
155
+ state . partition = 'live' ;
156
+ resp = await jsonPipe ( state , new PipelineRequest ( 'https://json-filter.com/?limit=10&offset=5' ) ) ;
130
157
assert . strictEqual ( resp . status , 200 ) ;
131
158
assert . deepStrictEqual ( await resp . json ( ) , {
132
159
':type' : 'sheet' ,
@@ -148,7 +175,7 @@ describe('JSON Pipe Test', () => {
148
175
assert . strictEqual ( resp . status , 404 ) ;
149
176
assert . deepStrictEqual ( Object . fromEntries ( resp . headers . entries ( ) ) , {
150
177
'x-error' : 'failed to load /config.json: 404' ,
151
- 'x-surrogate-key' : 'U_NW4adJU7Qazf-I pzrU-nNKQOUYNTEf ref--repo--owner_code kz8SoCaNqfp4ohQo foobar' ,
178
+ 'x-surrogate-key' : 'U_NW4adJU7Qazf-I pzrU-nNKQOUYNTEf ref--repo--owner_code kz8SoCaNqfp4ohQo foobar p_kz8SoCaNqfp4ohQo p_foobar ' ,
152
179
} ) ;
153
180
} ) ;
154
181
@@ -165,7 +192,7 @@ describe('JSON Pipe Test', () => {
165
192
assert . strictEqual ( resp . status , 200 ) ;
166
193
assert . deepStrictEqual ( Object . fromEntries ( resp . headers . entries ( ) ) , {
167
194
'content-type' : 'application/json' ,
168
- 'x-surrogate-key' : 'U_NW4adJU7Qazf-I pzrU-nNKQOUYNTEf ref--repo--owner_code kz8SoCaNqfp4ohQo foobar' ,
195
+ 'x-surrogate-key' : 'U_NW4adJU7Qazf-I pzrU-nNKQOUYNTEf ref--repo--owner_code kz8SoCaNqfp4ohQo foobar p_kz8SoCaNqfp4ohQo p_foobar ' ,
169
196
} ) ;
170
197
assert . deepStrictEqual ( await resp . json ( ) , {
171
198
public : {
@@ -193,7 +220,7 @@ describe('JSON Pipe Test', () => {
193
220
} ) ;
194
221
assert . deepStrictEqual ( Object . fromEntries ( resp . headers . entries ( ) ) , {
195
222
'content-type' : 'application/json' ,
196
- 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar' ,
223
+ 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar p_Atrz_qDg26DmSe9a p_foobar ' ,
197
224
'last-modified' : 'Wed, 12 Oct 2009 17:50:00 GMT' ,
198
225
} ) ;
199
226
} ) ;
@@ -214,7 +241,7 @@ describe('JSON Pipe Test', () => {
214
241
'access-control-allow-origin' : '*' ,
215
242
'content-security-policy' : 'default-src \'self\'' ,
216
243
'last-modified' : 'Wed, 12 Oct 2009 17:50:00 GMT' ,
217
- 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar' ,
244
+ 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar p_Atrz_qDg26DmSe9a p_foobar ' ,
218
245
'content-type' : 'application/json' ,
219
246
} ) ;
220
247
} ) ;
@@ -229,7 +256,7 @@ describe('JSON Pipe Test', () => {
229
256
'access-control-allow-origin' : '*' ,
230
257
'content-security-policy' : 'default-src \'self\'' ,
231
258
'x-error' : 'failed to load /en/index.json: 404' ,
232
- 'x-surrogate-key' : 'SIMSxecp2CJXqGYs ref--repo--owner_code Atrz_qDg26DmSe9a foobar' ,
259
+ 'x-surrogate-key' : 'SIMSxecp2CJXqGYs ref--repo--owner_code Atrz_qDg26DmSe9a foobar p_Atrz_qDg26DmSe9a p_foobar ' ,
233
260
} ) ;
234
261
} ) ;
235
262
@@ -244,8 +271,26 @@ describe('JSON Pipe Test', () => {
244
271
'x-amz-meta-redirect-location' : '/de/index.json' ,
245
272
} ,
246
273
} ) ,
247
- ) ;
248
- const resp = await jsonPipe ( state , new PipelineRequest ( 'https://json-filter.com/?limit=10&offset=5' ) ) ;
274
+ )
275
+ . reply (
276
+ 'helix-content-bus' ,
277
+ 'foobar/live/en/index.json' ,
278
+ new PipelineResponse ( TEST_SINGLE_SHEET , {
279
+ headers : {
280
+ 'content-type' : 'application/json' ,
281
+ 'x-amz-meta-redirect-location' : '/de/index.json' ,
282
+ } ,
283
+ } ) ,
284
+ ) ;
285
+ let resp = await jsonPipe ( state , new PipelineRequest ( 'https://json-filter.com/?limit=10&offset=5' ) ) ;
286
+ assert . strictEqual ( resp . status , 301 ) ;
287
+ assert . deepStrictEqual ( Object . fromEntries ( resp . headers . entries ( ) ) , {
288
+ 'location' : '/de/index.json' ,
289
+ 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar p_Atrz_qDg26DmSe9a p_foobar' ,
290
+ } ) ;
291
+ // live (code coverage)
292
+ state . partition = 'live' ;
293
+ resp = await jsonPipe ( state , new PipelineRequest ( 'https://json-filter.com/?limit=10&offset=5' ) ) ;
249
294
assert . strictEqual ( resp . status , 301 ) ;
250
295
assert . deepStrictEqual ( Object . fromEntries ( resp . headers . entries ( ) ) , {
251
296
'location' : '/de/index.json' ,
@@ -301,7 +346,7 @@ describe('JSON Pipe Test', () => {
301
346
const headers = Object . fromEntries ( resp . headers . entries ( ) ) ;
302
347
assert . deepStrictEqual ( headers , {
303
348
'last-modified' : 'Wed, 12 Oct 2009 17:50:00 GMT' ,
304
- 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar' ,
349
+ 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar p_Atrz_qDg26DmSe9a p_foobar ' ,
305
350
'content-type' : 'application/json' ,
306
351
} ) ;
307
352
} ) ;
@@ -333,7 +378,7 @@ describe('JSON Pipe Test', () => {
333
378
const headers = Object . fromEntries ( resp . headers . entries ( ) ) ;
334
379
assert . deepStrictEqual ( headers , {
335
380
'last-modified' : 'Wed, 12 Oct 2009 15:50:00 GMT' ,
336
- 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar' ,
381
+ 'x-surrogate-key' : 'Atrz_qDg26DmSe9a foobar p_Atrz_qDg26DmSe9a p_foobar ' ,
337
382
'content-type' : 'application/json' ,
338
383
} ) ;
339
384
} ) ;
0 commit comments