@@ -8,6 +8,11 @@ import {
8
8
import { runWrangler } from "./run-wrangler" ;
9
9
import { runInTempDir } from "./run-in-tmp" ;
10
10
11
+ interface KVNamespaceInfo {
12
+ title : string ;
13
+ id : string ;
14
+ }
15
+
11
16
describe ( "wrangler" , ( ) => {
12
17
runInTempDir ( ) ;
13
18
@@ -196,30 +201,30 @@ describe("wrangler", () => {
196
201
}
197
202
198
203
it ( "should list namespaces" , async ( ) => {
199
- const KVNamespaces = [
204
+ const kvNamespaces : KVNamespaceInfo [ ] = [
200
205
{ title : "title-1" , id : "id-1" } ,
201
206
{ title : "title-2" , id : "id-2" } ,
202
207
] ;
203
- mockListRequest ( KVNamespaces ) ;
208
+ mockListRequest ( kvNamespaces ) ;
204
209
const { error, stdout, stderr } = await runWrangler (
205
210
"kv:namespace list"
206
211
) ;
207
212
expect ( error ) . toMatchInlineSnapshot ( `undefined` ) ;
208
213
expect ( stderr ) . toMatchInlineSnapshot ( `""` ) ;
209
214
const namespaces = JSON . parse ( stdout ) ;
210
- expect ( namespaces ) . toEqual ( KVNamespaces ) ;
215
+ expect ( namespaces ) . toEqual ( kvNamespaces ) ;
211
216
} ) ;
212
217
213
218
it ( "should make multiple requests for paginated results" , async ( ) => {
214
219
// Create a lot of mock namespaces, so that the fetch requests will be paginated
215
- const KVNamespaces = [ ] ;
220
+ const kvNamespaces : KVNamespaceInfo [ ] = [ ] ;
216
221
for ( let i = 0 ; i < 550 ; i ++ ) {
217
- KVNamespaces . push ( { title : "title-" + i , id : "id-" + i } ) ;
222
+ kvNamespaces . push ( { title : "title-" + i , id : "id-" + i } ) ;
218
223
}
219
- const requests = mockListRequest ( KVNamespaces ) ;
224
+ const requests = mockListRequest ( kvNamespaces ) ;
220
225
const { stdout } = await runWrangler ( "kv:namespace list" ) ;
221
226
const namespaces = JSON . parse ( stdout ) ;
222
- expect ( namespaces ) . toEqual ( KVNamespaces ) ;
227
+ expect ( namespaces ) . toEqual ( kvNamespaces ) ;
223
228
expect ( requests . count ) . toEqual ( 6 ) ;
224
229
} ) ;
225
230
} ) ;
@@ -689,7 +694,7 @@ describe("wrangler", () => {
689
694
if ( expectedKeys . length <= keysPerRequest ) {
690
695
return createFetchResult ( expectedKeys ) ;
691
696
} else {
692
- const start = parseInt ( query . get ( "cursor" ) ) || 0 ;
697
+ const start = parseInt ( query . get ( "cursor" ) ?? "0" ) || 0 ;
693
698
const end = start + keysPerRequest ;
694
699
const cursor = end < expectedKeys . length ? end : undefined ;
695
700
return createFetchResult (
@@ -786,7 +791,7 @@ describe("wrangler", () => {
786
791
787
792
it ( "should make multiple requests for paginated results" , async ( ) => {
788
793
// Create a lot of mock keys, so that the fetch requests will be paginated
789
- const keys = [ ] ;
794
+ const keys : string [ ] = [ ] ;
790
795
for ( let i = 0 ; i < 550 ; i ++ ) {
791
796
keys . push ( "key-" + i ) ;
792
797
}
0 commit comments