@@ -140,10 +140,13 @@ describe('bundle upload', () => {
140140 ) ;
141141 }
142142
143- function respondWithBinaryCounts (
144- binaryCount : number ,
145- fingerprintBinaryCount : number ,
146- ) : void {
143+ function respondWithBinaryCounts ( {
144+ binaryCount,
145+ fingerprintBinaryCount,
146+ } : {
147+ binaryCount : number ;
148+ fingerprintBinaryCount : number ;
149+ } ) : void {
147150 harness . routes [ `GET ${ BINARY_COUNT_PATH } ` ] = ( ) =>
148151 Response . json ( { count : binaryCount } ) ;
149152 harness . routes [
@@ -155,7 +158,7 @@ describe('bundle upload', () => {
155158 harness . routes [ `POST ${ BUNDLES_PATH } ` ] = ( ) =>
156159 Response . json ( { ...READY_BUNDLE , status : 'uploading' } , { status : 201 } ) ;
157160 respondWithMissingFiles ( ) ;
158- respondWithBinaryCounts ( 1 , 1 ) ;
161+ respondWithBinaryCounts ( { binaryCount : 1 , fingerprintBinaryCount : 1 } ) ;
159162 harness . routes [ `PUT /v1/apps/${ DEMO_APP . id } /files/${ APP_JS_SHA256 } ` ] =
160163 request => {
161164 // The upload removes its temporary files when it ends, so the bytes are read as each request arrives.
@@ -178,10 +181,13 @@ describe('bundle upload', () => {
178181 Response . json ( READY_BUNDLE ) ;
179182 }
180183
181- function readRequest (
182- method : string ,
183- pathSuffix : string ,
184- ) : Request | undefined {
184+ function readRequest ( {
185+ method,
186+ pathSuffix,
187+ } : {
188+ method : string ;
189+ pathSuffix : string ;
190+ } ) : Request | undefined {
185191 return harness . requests . find (
186192 request =>
187193 request . method === method &&
@@ -201,11 +207,14 @@ describe('bundle upload', () => {
201207 undefined ,
202208 ) ;
203209
204- const createRequest = readRequest ( 'POST' , '/bundles' ) ;
205- const filesRequest = readRequest (
206- 'GET' ,
207- `/bundles/${ READY_BUNDLE . id } /files` ,
208- ) ;
210+ const createRequest = readRequest ( {
211+ method : 'POST' ,
212+ pathSuffix : '/bundles' ,
213+ } ) ;
214+ const filesRequest = readRequest ( {
215+ method : 'GET' ,
216+ pathSuffix : `/bundles/${ READY_BUNDLE . id } /files` ,
217+ } ) ;
209218 expect (
210219 Object . fromEntries ( new URL ( filesRequest ?. url ?? API_URL ) . searchParams ) ,
211220 ) . toEqual ( { isStored : 'false' , limit : '1000' , offset : '0' } ) ;
@@ -224,7 +233,10 @@ describe('bundle upload', () => {
224233 platforms : [ 'ios' ] ,
225234 signature : null ,
226235 } ) ;
227- const fileRequest = readRequest ( 'PUT' , `/files/${ APP_JS_SHA256 } ` ) ;
236+ const fileRequest = readRequest ( {
237+ method : 'PUT' ,
238+ pathSuffix : `/files/${ APP_JS_SHA256 } ` ,
239+ } ) ;
228240 expect ( fileRequest ) . toBeDefined ( ) ;
229241 expect ( fileRequest ?. headers . get ( 'content-type' ) ) . toBe ( 'application/gzip' ) ;
230242 expect ( Number ( fileRequest ?. headers . get ( 'content-length' ) ) ) . toBeGreaterThan (
@@ -235,12 +247,16 @@ describe('bundle upload', () => {
235247 Buffer . from ( ( await uploadedFileBytes ) ?? new ArrayBuffer ( 0 ) ) ,
236248 ) . toString ( ) ,
237249 ) . toBe ( APP_JS ) ;
238- expect ( readRequest ( 'PUT' , `/files/${ INDEX_SHA256 } ` ) ) . toBeUndefined ( ) ;
250+ expect (
251+ readRequest ( { method : 'PUT' , pathSuffix : `/files/${ INDEX_SHA256 } ` } ) ,
252+ ) . toBeUndefined ( ) ;
239253 const packEntries = await readPackEntries (
240254 ( await uploadedPackBytes ) ?? new ArrayBuffer ( 0 ) ,
241255 ) ;
242256 expect ( [ ...packEntries . keys ( ) ] ) . toEqual ( [ APP_JS_SHA256 , INDEX_SHA256 ] ) ;
243- expect ( readRequest ( 'POST' , '/complete' ) ) . toBeDefined ( ) ;
257+ expect (
258+ readRequest ( { method : 'POST' , pathSuffix : '/complete' } ) ,
259+ ) . toBeDefined ( ) ;
244260 expect ( harness . readLines ( ) ) . toEqual ( [
245261 'Uploaded bundle #17 · 1.4.2.' ,
246262 `ID ${ READY_BUNDLE . id } ` ,
@@ -262,7 +278,9 @@ describe('bundle upload', () => {
262278 undefined ,
263279 ) ;
264280
265- expect ( await readRequest ( 'POST' , '/bundles' ) ?. json ( ) ) . toMatchObject ( {
281+ expect (
282+ await readRequest ( { method : 'POST' , pathSuffix : '/bundles' } ) ?. json ( ) ,
283+ ) . toMatchObject ( {
266284 files : [
267285 { path : 'assets/app.js' , sha256 : APP_JS_SHA256 , sizeBytes : 14 } ,
268286 { path : 'index.html' , sha256 : INDEX_SHA256 , sizeBytes : 11 } ,
@@ -310,23 +328,23 @@ describe('bundle upload', () => {
310328 }
311329
312330 it ( "should warn on stderr when the app has binaries and none carries the bundle's fingerprint" , async ( ) => {
313- respondWithBinaryCounts ( 2 , 0 ) ;
331+ respondWithBinaryCounts ( { binaryCount : 2 , fingerprintBinaryCount : 0 } ) ;
314332
315333 await runBundleUpload ( ) ;
316334
317335 expect ( harness . readDiagnostics ( ) ) . toBe ( FINGERPRINT_WARNING ) ;
318336 } ) ;
319337
320338 it ( 'should stay silent when the app has no binary yet' , async ( ) => {
321- respondWithBinaryCounts ( 0 , 0 ) ;
339+ respondWithBinaryCounts ( { binaryCount : 0 , fingerprintBinaryCount : 0 } ) ;
322340
323341 await runBundleUpload ( ) ;
324342
325343 expect ( harness . readDiagnostics ( ) ) . not . toContain ( FINGERPRINT_WARNING ) ;
326344 } ) ;
327345
328346 it ( "should stay silent and count no other binary when a binary carries the bundle's fingerprint" , async ( ) => {
329- respondWithBinaryCounts ( 2 , 1 ) ;
347+ respondWithBinaryCounts ( { binaryCount : 2 , fingerprintBinaryCount : 1 } ) ;
330348
331349 await runBundleUpload ( ) ;
332350
@@ -396,7 +414,10 @@ describe('bundle upload', () => {
396414 ) ;
397415
398416 const { files, fingerprint, platforms, signature, version } =
399- ( await readRequest ( 'POST' , '/bundles' ) ?. json ( ) ) as {
417+ ( await readRequest ( {
418+ method : 'POST' ,
419+ pathSuffix : '/bundles' ,
420+ } ) ?. json ( ) ) as {
400421 files : object [ ] ;
401422 fingerprint : string ;
402423 platforms : string [ ] ;
@@ -426,14 +447,19 @@ describe('bundle upload', () => {
426447 it ( 'should sign the manifest with the private key file --private-key-path names' , async ( ) => {
427448 respondWithUploadRoutes ( ) ;
428449 const privateKeyPath = join ( projectDirectoryPath , 'private-key.pem' ) ;
429- writeSigningPrivateKeyFile ( privateKeyPath , SIGNING_PRIVATE_KEY ) ;
450+ writeSigningPrivateKeyFile ( privateKeyPath , {
451+ privateKey : SIGNING_PRIVATE_KEY ,
452+ } ) ;
430453
431454 await bundleUploadCommand . action (
432455 { config : listPublicKey ( ) , json : true , noGit : true , privateKeyPath } ,
433456 undefined ,
434457 ) ;
435458
436- const { signature } = ( await readRequest ( 'POST' , '/bundles' ) ?. json ( ) ) as {
459+ const { signature } = ( await readRequest ( {
460+ method : 'POST' ,
461+ pathSuffix : '/bundles' ,
462+ } ) ?. json ( ) ) as {
437463 signature : { keyId : string } ;
438464 } ;
439465 expect ( signature . keyId ) . toBe ( SIGNING_KEY . keyId ) ;
@@ -515,7 +541,9 @@ describe('bundle upload', () => {
515541 message : 'Which version label does the bundle carry?' ,
516542 } ) ,
517543 ) ;
518- expect ( await readRequest ( 'POST' , '/bundles' ) ?. json ( ) ) . toMatchObject ( {
544+ expect (
545+ await readRequest ( { method : 'POST' , pathSuffix : '/bundles' } ) ?. json ( ) ,
546+ ) . toMatchObject ( {
519547 version : '2.0.0' ,
520548 } ) ;
521549 } ) ;
@@ -579,7 +607,7 @@ describe('bundle upload', () => {
579607 { status : 201 } ,
580608 ) ;
581609 respondWithMissingFiles ( [ ] ) ;
582- respondWithBinaryCounts ( 1 , 1 ) ;
610+ respondWithBinaryCounts ( { binaryCount : 1 , fingerprintBinaryCount : 1 } ) ;
583611 harness . routes [ `PUT ${ BUNDLES_PATH } /${ READY_BUNDLE . id } /pack` ] = ( ) =>
584612 Response . json ( { sizeBytes : 1536 } ) ;
585613 harness . routes [ `POST ${ BUNDLES_PATH } /${ READY_BUNDLE . id } /complete` ] = ( ) =>
@@ -668,7 +696,9 @@ describe('bundle upload', () => {
668696 ) ;
669697
670698 expect ( runCommandLineVisibly ) . not . toHaveBeenCalled ( ) ;
671- expect ( await readRequest ( 'POST' , '/bundles' ) ?. json ( ) ) . toMatchObject ( {
699+ expect (
700+ await readRequest ( { method : 'POST' , pathSuffix : '/bundles' } ) ?. json ( ) ,
701+ ) . toMatchObject ( {
672702 files : [ expect . objectContaining ( { path : 'main.jsbundle' } ) ] ,
673703 platforms : [ 'ios' ] ,
674704 } ) ;
0 commit comments