@@ -9,8 +9,8 @@ vi.mock('../utils/rate-limit.js');
9
9
describe ( 'searchArchives' , ( ) => {
10
10
beforeEach ( ( ) => {
11
11
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 ( ( ) => { } ) ;
14
14
} ) ;
15
15
16
16
afterEach ( ( ) => {
@@ -29,7 +29,7 @@ describe('searchArchives', () => {
29
29
[ 'com,example)/' , '20231225120000' , 'https://example.com/' , 'text/html' , '200' , 'ABC123' , '1234' ]
30
30
] ) ;
31
31
32
- const result = await searchArchives ( { url : 'https://example.com' } ) ;
32
+ const result = await searchArchives ( { url : 'https://example.com' , limit : 10 } ) ;
33
33
34
34
expect ( result . success ) . toBe ( true ) ;
35
35
expect ( result . results ) . toHaveLength ( 1 ) ;
@@ -54,7 +54,7 @@ describe('searchArchives', () => {
54
54
[ 'urlkey' , 'timestamp' , 'original' , 'mimetype' , 'statuscode' , 'digest' , 'length' ]
55
55
] ) ;
56
56
57
- const result = await searchArchives ( { url : 'https://example.com' } ) ;
57
+ const result = await searchArchives ( { url : 'https://example.com' , limit : 10 } ) ;
58
58
59
59
expect ( result . success ) . toBe ( true ) ;
60
60
expect ( result . results ) . toEqual ( [ ] ) ;
@@ -92,7 +92,8 @@ describe('searchArchives', () => {
92
92
it ( 'should handle invalid date formats' , async ( ) => {
93
93
const result = await searchArchives ( {
94
94
url : 'https://example.com' ,
95
- from : 'invalid-date'
95
+ from : 'invalid-date' ,
96
+ limit : 10
96
97
} ) ;
97
98
98
99
expect ( result . success ) . toBe ( false ) ;
@@ -104,7 +105,7 @@ describe('searchArchives', () => {
104
105
new httpModule . HttpError ( 'Not found' , 404 )
105
106
) ;
106
107
107
- const result = await searchArchives ( { url : 'https://example.com' } ) ;
108
+ const result = await searchArchives ( { url : 'https://example.com' , limit : 10 } ) ;
108
109
109
110
expect ( result . success ) . toBe ( true ) ;
110
111
expect ( result . results ) . toEqual ( [ ] ) ;
@@ -116,14 +117,14 @@ describe('searchArchives', () => {
116
117
new httpModule . HttpError ( 'Server error' , 500 )
117
118
) ;
118
119
119
- const result = await searchArchives ( { url : 'https://example.com' } ) ;
120
+ const result = await searchArchives ( { url : 'https://example.com' , limit : 10 } ) ;
120
121
121
122
expect ( result . success ) . toBe ( false ) ;
122
123
expect ( result . message ) . toContain ( 'Failed to search archives' ) ;
123
124
} ) ;
124
125
125
126
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 } ) ;
127
128
128
129
expect ( result . success ) . toBe ( false ) ;
129
130
expect ( result . message ) . toContain ( 'Failed to search archives' ) ;
0 commit comments