|
| 1 | +import { describe, it, expect } from '@jest/globals'; |
| 2 | +import { ToolLoader } from '../../src/loaders/toolLoader.js'; |
| 3 | +import { PromptLoader } from '../../src/loaders/promptLoader.js'; |
| 4 | +import { ResourceLoader } from '../../src/loaders/resourceLoader.js'; |
| 5 | + |
| 6 | +describe('Loader TypeScript file support (tsx compatibility)', () => { |
| 7 | + describe('ToolLoader', () => { |
| 8 | + it('should accept .ts extension in config', () => { |
| 9 | + const loader = new ToolLoader('/tmp/test'); |
| 10 | + // Access the protected config via any cast |
| 11 | + const config = (loader as any).config; |
| 12 | + expect(config.extensions).toContain('.js'); |
| 13 | + expect(config.extensions).toContain('.ts'); |
| 14 | + }); |
| 15 | + |
| 16 | + it('should exclude .d.ts files', () => { |
| 17 | + const loader = new ToolLoader('/tmp/test'); |
| 18 | + const config = (loader as any).config; |
| 19 | + expect(config.excludedFiles).toContain('*.d.ts'); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should exclude TypeScript test files', () => { |
| 23 | + const loader = new ToolLoader('/tmp/test'); |
| 24 | + const config = (loader as any).config; |
| 25 | + expect(config.excludedFiles).toContain('*.test.ts'); |
| 26 | + expect(config.excludedFiles).toContain('*.spec.ts'); |
| 27 | + }); |
| 28 | + |
| 29 | + it('should exclude base class TypeScript files', () => { |
| 30 | + const loader = new ToolLoader('/tmp/test'); |
| 31 | + const config = (loader as any).config; |
| 32 | + expect(config.excludedFiles).toContain('BaseTool.ts'); |
| 33 | + }); |
| 34 | + }); |
| 35 | + |
| 36 | + describe('PromptLoader', () => { |
| 37 | + it('should accept .ts extension in config', () => { |
| 38 | + const loader = new PromptLoader('/tmp/test'); |
| 39 | + const config = (loader as any).config; |
| 40 | + expect(config.extensions).toContain('.js'); |
| 41 | + expect(config.extensions).toContain('.ts'); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should exclude .d.ts and test files', () => { |
| 45 | + const loader = new PromptLoader('/tmp/test'); |
| 46 | + const config = (loader as any).config; |
| 47 | + expect(config.excludedFiles).toContain('*.d.ts'); |
| 48 | + expect(config.excludedFiles).toContain('*.test.ts'); |
| 49 | + expect(config.excludedFiles).toContain('BasePrompt.ts'); |
| 50 | + }); |
| 51 | + }); |
| 52 | + |
| 53 | + describe('ResourceLoader', () => { |
| 54 | + it('should accept .ts extension in config', () => { |
| 55 | + const loader = new ResourceLoader('/tmp/test'); |
| 56 | + const config = (loader as any).config; |
| 57 | + expect(config.extensions).toContain('.js'); |
| 58 | + expect(config.extensions).toContain('.ts'); |
| 59 | + }); |
| 60 | + |
| 61 | + it('should exclude .d.ts and test files', () => { |
| 62 | + const loader = new ResourceLoader('/tmp/test'); |
| 63 | + const config = (loader as any).config; |
| 64 | + expect(config.excludedFiles).toContain('*.d.ts'); |
| 65 | + expect(config.excludedFiles).toContain('*.test.ts'); |
| 66 | + expect(config.excludedFiles).toContain('BaseResource.ts'); |
| 67 | + }); |
| 68 | + }); |
| 69 | +}); |
0 commit comments