Skip to content

Commit 1f6ad66

Browse files
committed
🧪 fix test
1 parent b3f9a0b commit 1f6ad66

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

src/util/http/pagination.test.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { paginate, paginateGenerator } from './pagination';
2+
import { AxiosHeaders } from 'axios';
23

34
function* fetchDataGen(chunkSize: number, items: number): any {
45
let itemsLeft = items;
@@ -90,7 +91,9 @@ describe('pagination (accumulating)', () => {
9091
status: 200,
9192
statusText: 'OK',
9293
headers: {},
93-
config: {},
94+
config: {
95+
headers: {} as AxiosHeaders,
96+
},
9497
});
9598

9699
const data = await paginate<Array<any>>(
@@ -129,7 +132,9 @@ describe('pagination (accumulating)', () => {
129132
status: 200,
130133
statusText: 'OK',
131134
headers: {},
132-
config: {},
135+
config: {
136+
headers: {} as AxiosHeaders,
137+
},
133138
});
134139

135140
const data = await paginate<Array<any>>(
@@ -185,7 +190,9 @@ describe('pagination (accumulating)', () => {
185190
status: 500,
186191
statusText: 'ERROR',
187192
headers: {},
188-
config: {},
193+
config: {
194+
headers: {},
195+
},
189196
});
190197
} else {
191198
return Promise.resolve({
@@ -195,7 +202,9 @@ describe('pagination (accumulating)', () => {
195202
status: 200,
196203
statusText: 'OK',
197204
headers: {},
198-
config: {},
205+
config: {
206+
headers: {} as AxiosHeaders,
207+
},
199208
});
200209
}
201210
};
@@ -291,7 +300,9 @@ describe('pagination (generator)', () => {
291300
status: 200,
292301
statusText: 'OK',
293302
headers: {},
294-
config: {},
303+
config: {
304+
headers: {} as AxiosHeaders,
305+
},
295306
});
296307

297308
const iterator = paginateGenerator(
@@ -333,7 +344,9 @@ describe('pagination (generator)', () => {
333344
status: 200,
334345
statusText: 'OK',
335346
headers: {},
336-
config: {},
347+
config: {
348+
headers: {} as AxiosHeaders,
349+
},
337350
});
338351

339352
const iterator = paginateGenerator(
@@ -399,7 +412,9 @@ describe('pagination (generator)', () => {
399412
status: 200,
400413
statusText: 'OK',
401414
headers: {},
402-
config: {},
415+
config: {
416+
headers: {} as AxiosHeaders,
417+
},
403418
});
404419
}
405420
};

src/util/http/pagination.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ export async function* paginateGenerator<T>(
2323
retryOnError?: RetryOnError,
2424
paginateId?: number,
2525
) {
26-
let response: AxiosResponse | undefined;
26+
let response: AxiosResponse | undefined = undefined;
2727

2828
while (!response || !isEof(response)) {
2929
try {
3030
if (response && delayMs) {
3131
await sleep(delayMs);
3232
}
3333

34-
const newResponse = await invokeNextRequest(response);
34+
const newResponse: AxiosResponse = await invokeNextRequest(response);
3535
const responseData = extractDataFromResponse(newResponse);
3636

3737
response = newResponse; // NOTE: due to potential retry (from within catch below), reassign response only as a last step

0 commit comments

Comments
 (0)