Skip to content

Commit 869922d

Browse files
Fix lint issues and missing imports
Fixed the unused variables and imported only used values in test Co-authored-by: sunnylqm <615282+sunnylqm@users.noreply.github.com>
1 parent cfc29af commit 869922d

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/utils/http-helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export const testUrls = async (urls?: string[]) => {
6060
let ret: string | null = null;
6161
try {
6262
ret = await promiseAny(urls.map(ping));
63-
} catch (e) {
63+
} catch (_e) {
6464
// fallback to urls[0]
6565
}
6666
if (ret) {

tests/http-helper.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
import { describe, expect, test, beforeEach, afterEach, mock } from 'bun:test';
2+
import { afterEach, describe, expect, mock, test } from 'bun:test';
33

44
const runtimeFetchMock = mock(() => Promise.resolve({ status: 200 }));
55
mock.module('../src/utils/runtime', () => ({
@@ -62,17 +62,24 @@ describe('testUrls edge cases', () => {
6262
return Promise.reject(new Error('fail'));
6363
});
6464

65-
const result = await testUrls(['http://fail.local', 'http://success.local']);
65+
const result = await testUrls([
66+
'http://fail.local',
67+
'http://success.local',
68+
]);
6669
expect(result).toBe('http://success.local');
6770
});
6871

6972
test('Fastest Response: returns the URL that resolves first', async () => {
7073
runtimeFetchMock.mockImplementation((url: string) => {
7174
if (url === 'http://fast.local') {
72-
return new Promise((resolve) => setTimeout(() => resolve({ status: 200 }), 10));
75+
return new Promise((resolve) =>
76+
setTimeout(() => resolve({ status: 200 }), 10),
77+
);
7378
}
7479
if (url === 'http://slow.local') {
75-
return new Promise((resolve) => setTimeout(() => resolve({ status: 200 }), 50));
80+
return new Promise((resolve) =>
81+
setTimeout(() => resolve({ status: 200 }), 50),
82+
);
7683
}
7784
return Promise.reject(new Error('fail'));
7885
});

0 commit comments

Comments
 (0)