Skip to content

Commit 8e0b7fc

Browse files
committed
fix: resolve TypeScript errors in test files
1 parent 35c099c commit 8e0b7fc

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/tools/retrieve.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ vi.mock('../utils/rate-limit.js');
99
describe('getArchivedUrl', () => {
1010
beforeEach(() => {
1111
vi.clearAllMocks();
12-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue();
13-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation();
12+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined as any);
13+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
1414
});
1515

1616
afterEach(() => {

src/tools/save.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ vi.mock('../utils/rate-limit.js');
99
describe('saveUrl', () => {
1010
beforeEach(() => {
1111
vi.clearAllMocks();
12-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue();
13-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation();
12+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined as any);
13+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
1414
});
1515

1616
afterEach(() => {

src/tools/search.test.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ vi.mock('../utils/rate-limit.js');
99
describe('searchArchives', () => {
1010
beforeEach(() => {
1111
vi.clearAllMocks();
12-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue();
13-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation();
12+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined as any);
13+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
1414
});
1515

1616
afterEach(() => {
@@ -29,7 +29,7 @@ describe('searchArchives', () => {
2929
['com,example)/', '20231225120000', 'https://example.com/', 'text/html', '200', 'ABC123', '1234']
3030
]);
3131

32-
const result = await searchArchives({ url: 'https://example.com' });
32+
const result = await searchArchives({ url: 'https://example.com', limit: 10 });
3333

3434
expect(result.success).toBe(true);
3535
expect(result.results).toHaveLength(1);
@@ -54,7 +54,7 @@ describe('searchArchives', () => {
5454
['urlkey', 'timestamp', 'original', 'mimetype', 'statuscode', 'digest', 'length']
5555
]);
5656

57-
const result = await searchArchives({ url: 'https://example.com' });
57+
const result = await searchArchives({ url: 'https://example.com', limit: 10 });
5858

5959
expect(result.success).toBe(true);
6060
expect(result.results).toEqual([]);
@@ -92,7 +92,8 @@ describe('searchArchives', () => {
9292
it('should handle invalid date formats', async () => {
9393
const result = await searchArchives({
9494
url: 'https://example.com',
95-
from: 'invalid-date'
95+
from: 'invalid-date',
96+
limit: 10
9697
});
9798

9899
expect(result.success).toBe(false);
@@ -104,7 +105,7 @@ describe('searchArchives', () => {
104105
new httpModule.HttpError('Not found', 404)
105106
);
106107

107-
const result = await searchArchives({ url: 'https://example.com' });
108+
const result = await searchArchives({ url: 'https://example.com', limit: 10 });
108109

109110
expect(result.success).toBe(true);
110111
expect(result.results).toEqual([]);
@@ -116,14 +117,14 @@ describe('searchArchives', () => {
116117
new httpModule.HttpError('Server error', 500)
117118
);
118119

119-
const result = await searchArchives({ url: 'https://example.com' });
120+
const result = await searchArchives({ url: 'https://example.com', limit: 10 });
120121

121122
expect(result.success).toBe(false);
122123
expect(result.message).toContain('Failed to search archives');
123124
});
124125

125126
it('should handle invalid URLs', async () => {
126-
const result = await searchArchives({ url: 'not-a-url' });
127+
const result = await searchArchives({ url: 'not-a-url', limit: 10 });
127128

128129
expect(result.success).toBe(false);
129130
expect(result.message).toContain('Failed to search archives');

src/tools/status.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ vi.mock('../utils/rate-limit.js');
99
describe('checkArchiveStatus', () => {
1010
beforeEach(() => {
1111
vi.clearAllMocks();
12-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue();
13-
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation();
12+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'waitForSlot').mockResolvedValue(undefined as any);
13+
vi.spyOn(rateLimitModule.waybackRateLimiter, 'recordRequest').mockImplementation(() => {});
1414
});
1515

1616
afterEach(() => {

0 commit comments

Comments
 (0)