|
3 | 3 | * Tests cover: DbVersioning, Tool Handlers, Utility Functions |
4 | 4 | */ |
5 | 5 |
|
6 | | -import { describe, it, expect, vi, beforeEach, afterEach, type Mock } from 'vitest'; |
| 6 | +import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; |
7 | 7 | import fs from 'fs'; |
8 | 8 |
|
9 | 9 | // ============================================================================ |
@@ -809,90 +809,3 @@ describe('Version Comparison Edge Cases', () => { |
809 | 809 | expect(versioning.compareVersions('1.0.0', '2.0.0')).toBe(-1); |
810 | 810 | }); |
811 | 811 | }); |
812 | | - |
813 | | -// ============================================================================ |
814 | | -// ModExamplesService Tests |
815 | | -// ============================================================================ |
816 | | - |
817 | | -describe('ModExamplesService', () => { |
818 | | - let ModExamplesService: typeof import('./services/mod-examples-service.js').ModExamplesService; |
819 | | - let mockDb: { prepare: Mock; close: Mock }; |
820 | | - let mockPrepare: Mock; |
821 | | - let mockGet: Mock; |
822 | | - let mockAll: Mock; |
823 | | - |
824 | | - beforeEach(async () => { |
825 | | - vi.resetModules(); |
826 | | - |
827 | | - mockGet = vi.fn(); |
828 | | - mockAll = vi.fn(); |
829 | | - mockPrepare = vi.fn().mockReturnValue({ |
830 | | - get: mockGet, |
831 | | - all: mockAll, |
832 | | - }); |
833 | | - mockDb = { |
834 | | - prepare: mockPrepare, |
835 | | - close: vi.fn(), |
836 | | - }; |
837 | | - |
838 | | - vi.doMock('better-sqlite3', () => { |
839 | | - return { |
840 | | - default: vi.fn(function () { |
841 | | - return mockDb; |
842 | | - }), |
843 | | - }; |
844 | | - }); |
845 | | - |
846 | | - const module = await import('./services/mod-examples-service.js'); |
847 | | - ModExamplesService = module.ModExamplesService; |
848 | | - }); |
849 | | - |
850 | | - afterEach(() => { |
851 | | - vi.restoreAllMocks(); |
852 | | - }); |
853 | | - |
854 | | - it('searchExamples should return empty array when no results', () => { |
855 | | - mockAll.mockReturnValue([]); |
856 | | - const service = new ModExamplesService(); |
857 | | - const results = service.searchExamples({ query: 'test' }); |
858 | | - expect(results).toEqual([]); |
859 | | - }); |
860 | | - |
861 | | - it('searchExamples should parse JSON fields correctly', () => { |
862 | | - const mockRow = { |
863 | | - id: 1, |
864 | | - mod_name: 'TestMod', |
865 | | - mod_repo: 'test/repo', |
866 | | - file_path: 'src/Test.java', |
867 | | - file_url: 'http://example.com', |
868 | | - start_line: 1, |
869 | | - end_line: 10, |
870 | | - title: 'Test Example', |
871 | | - code: 'code', |
872 | | - language: 'java', |
873 | | - caption: 'caption', |
874 | | - explanation: 'explanation', |
875 | | - pattern_type: 'mixin', |
876 | | - complexity: 'beginner', |
877 | | - category: 'items', |
878 | | - categoryName: 'Items', |
879 | | - bestPractices: '["practice"]', |
880 | | - potentialPitfalls: '["pitfall"]', |
881 | | - useCases: '["usecase"]', |
882 | | - keywords: '["keyword"]', |
883 | | - minecraftConcepts: '["concept"]', |
884 | | - qualityScore: 100, |
885 | | - isFeatured: 1, |
886 | | - tags: '["tag"]', |
887 | | - imports: '[{"path":"p","type":"t","isCritical":true}]', |
888 | | - apiReferences: '[{"className":"c","apiType":"a"}]', |
889 | | - }; |
890 | | - mockAll.mockReturnValue([mockRow]); |
891 | | - |
892 | | - const service = new ModExamplesService(); |
893 | | - const results = service.searchExamples({ query: 'test' }); |
894 | | - |
895 | | - expect(results[0].bestPractices).toEqual(['practice']); |
896 | | - expect(results[0].imports).toHaveLength(1); |
897 | | - }); |
898 | | -}); |
0 commit comments