Skip to content

Commit 00d04c2

Browse files
committed
Fix lint and prettier
1 parent 69517bc commit 00d04c2

File tree

3 files changed

+42
-28
lines changed

3 files changed

+42
-28
lines changed

tests/apiClient.spec.ts

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ describe('APIClient', () => {
657657
append: jest.fn(),
658658
[Symbol.toStringTag]: 'FormData',
659659
} as any;
660-
660+
661661
const options = client.requestOptions({
662662
path: '/test',
663663
method: 'POST',
@@ -676,8 +676,10 @@ describe('APIClient', () => {
676676
json: jest.fn().mockRejectedValue(new Error('Unexpected token')),
677677
headers: new Map(),
678678
};
679-
680-
await expect(client.requestWithResponse(invalidJsonResponse as any)).rejects.toThrow(
679+
680+
await expect(
681+
client.requestWithResponse(invalidJsonResponse as any)
682+
).rejects.toThrow(
681683
'Could not parse response from the server: invalid json content'
682684
);
683685
});
@@ -694,8 +696,10 @@ describe('APIClient', () => {
694696
headers: new Map(),
695697
buffer: jest.fn().mockResolvedValue(Buffer.from(testData)),
696698
};
697-
698-
fetchMock.mockImplementationOnce(() => Promise.resolve(mockResp as any));
699+
700+
fetchMock.mockImplementationOnce(() =>
701+
Promise.resolve(mockResp as any)
702+
);
699703

700704
const result = await client.requestRaw({
701705
path: '/test',
@@ -718,8 +722,10 @@ describe('APIClient', () => {
718722
headers: new Map(),
719723
body: mockStream,
720724
};
721-
722-
fetchMock.mockImplementationOnce(() => Promise.resolve(mockResp as any));
725+
726+
fetchMock.mockImplementationOnce(() =>
727+
Promise.resolve(mockResp as any)
728+
);
723729

724730
const result = await client.requestStream({
725731
path: '/test',
@@ -738,13 +744,17 @@ describe('APIClient', () => {
738744
headers: new Map(),
739745
body: null,
740746
};
741-
742-
fetchMock.mockImplementationOnce(() => Promise.resolve(mockResp as any));
743747

744-
await expect(client.requestStream({
745-
path: '/test',
746-
method: 'GET',
747-
})).rejects.toThrow('No response body');
748+
fetchMock.mockImplementationOnce(() =>
749+
Promise.resolve(mockResp as any)
750+
);
751+
752+
await expect(
753+
client.requestStream({
754+
path: '/test',
755+
method: 'GET',
756+
})
757+
).rejects.toThrow('No response body');
748758
});
749759
});
750760
});

tests/utils.spec.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,18 +511,20 @@ describe('streamToBase64', () => {
511511

512512
it('should handle stream errors', async () => {
513513
const errorStream = new Readable({
514-
read() {
514+
read(): void {
515515
// Implement _read to avoid the "not implemented" error
516-
}
516+
},
517517
});
518518
const testError = new Error('Stream error test');
519-
519+
520520
// Emit error after a short delay to ensure the error handler is set up
521521
setTimeout(() => {
522522
errorStream.emit('error', testError);
523523
}, 10);
524524

525-
await expect(streamToBase64(errorStream)).rejects.toThrow('Stream error test');
525+
await expect(streamToBase64(errorStream)).rejects.toThrow(
526+
'Stream error test'
527+
);
526528
});
527529

528530
it('should handle empty stream', async () => {

tests/utils/fetchWrapper.spec.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,41 +193,41 @@ describe('fetchWrapper (main)', () => {
193193
it('should handle dynamic import for getFetch when no global fetch', async () => {
194194
// Clear the module cache to ensure fresh import
195195
jest.resetModules();
196-
196+
197197
// Remove global fetch but keep global object
198198
delete (global as any).fetch;
199199

200200
const { getFetch } = await import('../../src/utils/fetchWrapper.js');
201201
const fetch = await getFetch();
202-
202+
203203
expect(mockDynamicImportMain).toHaveBeenCalledWith('node-fetch');
204204
expect(fetch).toBe(mockNodeFetchMain.default);
205205
});
206206

207207
it('should handle dynamic import for getRequest when no global Request', async () => {
208208
// Clear the module cache to ensure fresh import
209209
jest.resetModules();
210-
210+
211211
// Remove global Request but keep global object
212212
delete (global as any).Request;
213213

214214
const { getRequest } = await import('../../src/utils/fetchWrapper.js');
215215
const Request = await getRequest();
216-
216+
217217
expect(mockDynamicImportMain).toHaveBeenCalledWith('node-fetch');
218218
expect(Request).toBe(mockNodeFetchMain.Request);
219219
});
220220

221221
it('should handle dynamic import for getResponse when no global Response', async () => {
222222
// Clear the module cache to ensure fresh import
223223
jest.resetModules();
224-
224+
225225
// Remove global Response but keep global object
226226
delete (global as any).Response;
227227

228228
const { getResponse } = await import('../../src/utils/fetchWrapper.js');
229229
const Response = await getResponse();
230-
230+
231231
expect(mockDynamicImportMain).toHaveBeenCalledWith('node-fetch');
232232
expect(Response).toBe(mockNodeFetchMain.Response);
233233
});
@@ -236,25 +236,27 @@ describe('fetchWrapper (main)', () => {
236236
// Clear the module cache to ensure fresh import
237237
jest.resetModules();
238238
jest.clearAllMocks();
239-
239+
240240
// Remove all global objects
241241
delete (global as any).fetch;
242242
delete (global as any).Request;
243243
delete (global as any).Response;
244244

245-
const { getFetch, getRequest, getResponse } = await import('../../src/utils/fetchWrapper.js');
246-
245+
const { getFetch, getRequest, getResponse } = await import(
246+
'../../src/utils/fetchWrapper.js'
247+
);
248+
247249
// First call should trigger dynamic import
248250
await getFetch();
249251
// Note: Each function may call the dynamic import separately in the current implementation
250252
// This test verifies the behavior works correctly rather than enforcing specific internal implementation
251253
expect(mockDynamicImportMain).toHaveBeenCalledWith('node-fetch');
252-
254+
253255
// Subsequent calls should work correctly
254256
const fetchResult = await getFetch();
255257
const requestResult = await getRequest();
256258
const responseResult = await getResponse();
257-
259+
258260
// Verify all functions return the expected mocked objects
259261
expect(fetchResult).toBe(mockNodeFetchMain.default);
260262
expect(requestResult).toBe(mockNodeFetchMain.Request);

0 commit comments

Comments
 (0)