1- import { vi } from ' vitest' ;
1+ import { vi } from " vitest" ;
22
33import { parseArgs , processRule } from "./args.js" ;
44
@@ -20,7 +20,6 @@ describe("parseArgs", () => {
2020 expect ( result ) . toEqual ( { } ) ;
2121 } ) ;
2222
23-
2423 it ( "should set resume to true when --resume flag is present" , ( ) => {
2524 process . argv = [ "node" , "script.js" , "--resume" ] ;
2625 const result = parseArgs ( ) ;
@@ -33,7 +32,6 @@ describe("parseArgs", () => {
3332 expect ( result . readonly ) . toBe ( true ) ;
3433 } ) ;
3534
36-
3735 it ( "should parse config path from --config flag" , ( ) => {
3836 process . argv = [ "node" , "script.js" , "--config" , "/path/to/config.yaml" ] ;
3937 const result = parseArgs ( ) ;
@@ -189,8 +187,7 @@ describe("parseArgs", () => {
189187 it ( "should handle empty arguments array" , ( ) => {
190188 process . argv = [ "node" , "script.js" ] ;
191189 const result = parseArgs ( ) ;
192- expect ( result ) . toEqual ( {
193- } ) ;
190+ expect ( result ) . toEqual ( { } ) ;
194191 } ) ;
195192
196193 it ( "should handle multiple boolean flags" , ( ) => {
@@ -224,15 +221,15 @@ describe("processRule (loadRuleFromHub integration)", () => {
224221 // Mock fetch for hub tests
225222 const originalFetch = global . fetch ;
226223 const mockFetch = vi . fn ( ) as any ;
227-
224+
228225 beforeAll ( ( ) => {
229226 global . fetch = mockFetch ;
230227 } ) ;
231228
232229 afterAll ( ( ) => {
233230 global . fetch = originalFetch ;
234231 } ) ;
235-
232+
236233 beforeEach ( ( ) => {
237234 mockFetch . mockClear ( ) ;
238235 } ) ;
@@ -242,22 +239,26 @@ describe("processRule (loadRuleFromHub integration)", () => {
242239 // Create a mock zip file containing a markdown rule
243240 const JSZip = ( await import ( "jszip" ) ) . default ;
244241 const zip = new JSZip ( ) ;
245- const ruleContent = "# Sentry Next.js Rule\n\nThis is a sample rule for Sentry integration with Next.js applications." ;
242+ const ruleContent =
243+ "# Sentry Next.js Rule\n\nThis is a sample rule for Sentry integration with Next.js applications." ;
246244 zip . file ( "rule.md" , ruleContent ) ;
247-
245+
248246 const zipBuffer = await zip . generateAsync ( { type : "arraybuffer" } ) ;
249-
247+
250248 // Mock successful fetch response
251249 mockFetch . mockResolvedValue ( {
252250 ok : true ,
253251 arrayBuffer : ( ) => Promise . resolve ( zipBuffer ) ,
254252 } as Response ) ;
255253
256254 const result = await processRule ( "continuedev/sentry-nextjs" ) ;
257-
255+
258256 expect ( result ) . toBe ( ruleContent ) ;
259257 expect ( mockFetch ) . toHaveBeenCalledWith (
260- new URL ( "v0/continuedev/sentry-nextjs/latest/download" , "https://api.continue.dev/" )
258+ new URL (
259+ "v0/continuedev/sentry-nextjs/latest/download" ,
260+ "https://api.continue.dev/" ,
261+ ) ,
261262 ) ;
262263 } ) ;
263264
@@ -269,38 +270,38 @@ describe("processRule (loadRuleFromHub integration)", () => {
269270 } as Response ) ;
270271
271272 await expect ( processRule ( "continuedev/nonexistent-rule" ) ) . rejects . toThrow (
272- 'Failed to load rule from hub "continuedev/nonexistent-rule": HTTP 404: Not Found'
273+ 'Failed to load rule from hub "continuedev/nonexistent-rule": HTTP 404: Not Found' ,
273274 ) ;
274275 } ) ;
275276
276277 it ( "should handle network errors when loading from hub" , async ( ) => {
277278 mockFetch . mockRejectedValue ( new Error ( "Network error" ) ) ;
278279
279280 await expect ( processRule ( "continuedev/sentry-nextjs" ) ) . rejects . toThrow (
280- 'Failed to load rule from hub "continuedev/sentry-nextjs": Network error'
281+ 'Failed to load rule from hub "continuedev/sentry-nextjs": Network error' ,
281282 ) ;
282283 } ) ;
283284
284285 it ( "should handle invalid slug format" , async ( ) => {
285286 // "invalid-slug" doesn't contain "/" so it's treated as direct content, not a hub slug
286287 // Let's test with a slug that has wrong format but contains "/"
287288 await expect ( processRule ( "invalid/slug/too/many/parts" ) ) . rejects . toThrow (
288- 'Invalid hub slug format. Expected "owner/package", got: invalid/slug/too/many/parts'
289+ 'Invalid hub slug format. Expected "owner/package", got: invalid/slug/too/many/parts' ,
289290 ) ;
290291 } ) ;
291292
292293 it ( "should handle empty zip file" , async ( ) => {
293294 const JSZip = ( await import ( "jszip" ) ) . default ;
294295 const zip = new JSZip ( ) ;
295296 const zipBuffer = await zip . generateAsync ( { type : "arraybuffer" } ) ;
296-
297+
297298 mockFetch . mockResolvedValue ( {
298299 ok : true ,
299300 arrayBuffer : ( ) => Promise . resolve ( zipBuffer ) ,
300301 } as Response ) ;
301302
302303 await expect ( processRule ( "continuedev/empty-rule" ) ) . rejects . toThrow (
303- 'Failed to load rule from hub "continuedev/empty-rule": No rule content found in downloaded zip file'
304+ 'Failed to load rule from hub "continuedev/empty-rule": No rule content found in downloaded zip file' ,
304305 ) ;
305306 } ) ;
306307
@@ -309,14 +310,14 @@ describe("processRule (loadRuleFromHub integration)", () => {
309310 const zip = new JSZip ( ) ;
310311 zip . folder ( "docs" ) ; // Create a directory but no files
311312 const zipBuffer = await zip . generateAsync ( { type : "arraybuffer" } ) ;
312-
313+
313314 mockFetch . mockResolvedValue ( {
314315 ok : true ,
315316 arrayBuffer : ( ) => Promise . resolve ( zipBuffer ) ,
316317 } as Response ) ;
317318
318319 await expect ( processRule ( "continuedev/directory-only" ) ) . rejects . toThrow (
319- 'Failed to load rule from hub "continuedev/directory-only": No rule content found in downloaded zip file'
320+ 'Failed to load rule from hub "continuedev/directory-only": No rule content found in downloaded zip file' ,
320321 ) ;
321322 } ) ;
322323
@@ -325,20 +326,20 @@ describe("processRule (loadRuleFromHub integration)", () => {
325326 const zip = new JSZip ( ) ;
326327 const mdContent = "# Main Rule\n\nThis is the markdown rule content." ;
327328 const txtContent = "This is just a text file." ;
328-
329+
329330 zip . file ( "README.txt" , txtContent ) ;
330331 zip . file ( "rule.md" , mdContent ) ;
331332 zip . file ( "package.json" , '{"name": "test"}' ) ;
332-
333+
333334 const zipBuffer = await zip . generateAsync ( { type : "arraybuffer" } ) ;
334-
335+
335336 mockFetch . mockResolvedValue ( {
336337 ok : true ,
337338 arrayBuffer : ( ) => Promise . resolve ( zipBuffer ) ,
338339 } as Response ) ;
339340
340341 const result = await processRule ( "continuedev/mixed-files" ) ;
341-
342+
342343 expect ( result ) . toBe ( mdContent ) ;
343344 } ) ;
344345
@@ -347,33 +348,33 @@ describe("processRule (loadRuleFromHub integration)", () => {
347348 const zip = new JSZip ( ) ;
348349 const rule1Content = "# First Rule\n\nThis is the first rule." ;
349350 const rule2Content = "# Second Rule\n\nThis is the second rule." ;
350-
351+
351352 zip . file ( "rule1.md" , rule1Content ) ;
352353 zip . file ( "rule2.md" , rule2Content ) ;
353-
354+
354355 const zipBuffer = await zip . generateAsync ( { type : "arraybuffer" } ) ;
355-
356+
356357 mockFetch . mockResolvedValue ( {
357358 ok : true ,
358359 arrayBuffer : ( ) => Promise . resolve ( zipBuffer ) ,
359360 } as Response ) ;
360361
361362 const result = await processRule ( "continuedev/multiple-rules" ) ;
362-
363+
363364 // Should use the first markdown file found (alphabetically)
364365 expect ( result ) . toBe ( rule1Content ) ;
365366 } ) ;
366367
367368 it ( "should handle malformed zip files" , async ( ) => {
368369 const invalidZipBuffer = new ArrayBuffer ( 10 ) ;
369-
370+
370371 mockFetch . mockResolvedValue ( {
371372 ok : true ,
372373 arrayBuffer : ( ) => Promise . resolve ( invalidZipBuffer ) ,
373374 } as Response ) ;
374375
375376 await expect ( processRule ( "continuedev/corrupted-zip" ) ) . rejects . toThrow (
376- 'Failed to load rule from hub "continuedev/corrupted-zip"'
377+ 'Failed to load rule from hub "continuedev/corrupted-zip"' ,
377378 ) ;
378379 } ) ;
379380 } ) ;
@@ -384,7 +385,7 @@ describe("processRule (loadRuleFromHub integration)", () => {
384385 const zip = new JSZip ( ) ;
385386 zip . file ( "rule.md" , "# Hub Rule" ) ;
386387 const zipBuffer = await zip . generateAsync ( { type : "arraybuffer" } ) ;
387-
388+
388389 mockFetch . mockResolvedValue ( {
389390 ok : true ,
390391 arrayBuffer : ( ) => Promise . resolve ( zipBuffer ) ,
@@ -406,9 +407,9 @@ describe("processRule (loadRuleFromHub integration)", () => {
406407 // This would be treated as a file path, not a hub slug
407408 // since it starts with "."
408409 await expect ( processRule ( "./owner/package" ) ) . rejects . toThrow (
409- 'Failed to read rule file "./owner/package": Rule file not found'
410+ 'Failed to read rule file "./owner/package": Rule file not found' ,
410411 ) ;
411412 expect ( mockFetch ) . not . toHaveBeenCalled ( ) ;
412413 } ) ;
413414 } ) ;
414- } ) ;
415+ } ) ;
0 commit comments