diff --git a/src/spellcheck/tests/_quick_features.test.ts b/src/spellcheck/tests/_quick_features.test.ts new file mode 100644 index 0000000..fda07cc --- /dev/null +++ b/src/spellcheck/tests/_quick_features.test.ts @@ -0,0 +1,56 @@ +import { describe, test, expect, beforeEach } from 'vitest'; +import { + CapitalizationFeature, + CapitalizationFeatureFactory, + GrammarPatternFeature, + GrammarPatternFeatureFactory, + FeatureManager +} from '../features'; + +describe('CapitalizationFeature', () => { + let feature: CapitalizationFeature; + + beforeEach(() => { + feature = CapitalizationFeatureFactory.createDefault(); + }); + + test('should detect sentence capitalization errors', async () => { + const text = 'this is a sentence. another sentence here.'; + const results = await feature.checkText(text); + expect(results).toHaveLength(2); + }); +}); + +describe('GrammarPatternFeature', () => { + let feature: GrammarPatternFeature; + + beforeEach(() => { + feature = GrammarPatternFeatureFactory.createDefault(); + }); + + test('should detect a/an errors', async () => { + const text = 'I have a apple and an banana.'; + const results = await feature.checkText(text); + const appleError = results.find(r => r.originalText === 'a apple'); + expect(appleError).toBeDefined(); + }); +}); + +describe('FeatureManager Integration', () => { + let manager: FeatureManager; + + beforeEach(() => { + manager = new FeatureManager(); + }); + + test('should manage multiple features', async () => { + const capitalization = CapitalizationFeatureFactory.createDefault(); + const grammar = GrammarPatternFeatureFactory.createDefault(); + manager.addFeature(capitalization); + manager.addFeature(grammar); + await manager.initializeAll(); + const text = 'this is wrong. I have a apple.'; + const results = await manager.checkText(text); + expect(results.length).toBeGreaterThan(1); + }); +});