@@ -762,4 +762,58 @@ describe('list', () => {
762
762
expect ( directories ) . toEqual ( [ ] )
763
763
expect ( mockStore . fulfilled ) . toBeTruthy ( )
764
764
} )
765
+
766
+ test ( 'Handles missing content automatic pagination' , async ( ) => {
767
+ const mockStore = new MockFetch ( ) . get ( {
768
+ headers : { authorization : `Bearer ${ edgeToken } ` } ,
769
+ response : new Response ( '<not_found>' , { status : 404 } ) ,
770
+ url : `${ edgeURL } /${ siteID } /site:${ storeName } ?prefix=group%2F` ,
771
+ } )
772
+
773
+ globalThis . fetch = mockStore . fetch
774
+
775
+ const store = getStore ( {
776
+ edgeURL,
777
+ name : storeName ,
778
+ token : edgeToken ,
779
+ siteID,
780
+ } )
781
+
782
+ const { blobs } = await store . list ( {
783
+ prefix : 'group/' ,
784
+ } )
785
+
786
+ expect ( blobs ) . toEqual ( [ ] )
787
+ expect ( mockStore . fulfilled ) . toBeTruthy ( )
788
+ } )
789
+
790
+ test ( 'Handles missing content manual pagination' , async ( ) => {
791
+ const mockStore = new MockFetch ( ) . get ( {
792
+ headers : { authorization : `Bearer ${ edgeToken } ` } ,
793
+ response : new Response ( '<not_found>' , { status : 404 } ) ,
794
+ url : `${ edgeURL } /${ siteID } /site:${ storeName } ` ,
795
+ } )
796
+
797
+ globalThis . fetch = mockStore . fetch
798
+
799
+ const store = getStore ( {
800
+ edgeURL,
801
+ name : storeName ,
802
+ token : edgeToken ,
803
+ siteID,
804
+ } )
805
+ const result : ListResult = {
806
+ blobs : [ ] ,
807
+ directories : [ ] ,
808
+ }
809
+
810
+ for await ( const entry of store . list ( { paginate : true } ) ) {
811
+ result . blobs . push ( ...entry . blobs )
812
+ result . directories . push ( ...entry . directories )
813
+ }
814
+
815
+ expect ( result . blobs ) . toEqual ( [ ] )
816
+ expect ( result . directories ) . toEqual ( [ ] )
817
+ expect ( mockStore . fulfilled ) . toBeTruthy ( )
818
+ } )
765
819
} )
0 commit comments