import { test, expect } from 'vitest'; import { grammarNotes } from './grammar.js'; const terms = (label) => grammarNotes(label).map((n) => n.term); test('a Greek verb is explained part by part', () => { const notes = grammarNotes('Verb - Aorist Indicative Active - 3rd Person Singular'); expect(notes.map((n) => n.term)).toEqual(['Verb', 'Aorist', 'Indicative', 'Active', '3rd person singular']); expect(notes.find((n) => n.term === 'Aorist').meaning).toMatch(/as a whole/); expect(notes.at(-1).meaning).toBe('he / she / it / they (one).'); }); test('nouns and articles give their case', () => { expect(terms('Noun - Nominative Masculine Singular')).toEqual(['Noun', 'Nominative']); expect(terms('Article - Genitive Neuter Plural')).toEqual(['Article', 'Genitive']); expect(terms('Personal / Relative Pronoun - Accusative 1st Person Singular')).toContain('Accusative'); }); test('moods, participles and voices that share words are not double counted', () => { expect(terms('Verb - Present Participle Middle or Passive - Nominative Masculine Singular')).toEqual(['Verb', 'Present', 'Participle', 'Middle or passive', 'Nominative']); expect(terms('Verb - Perfect Infinitive Active')).toEqual(['Verb', 'Perfect', 'Infinitive', 'Active']); }); test('a Hebrew verb is read with Hebrew meanings, not Greek ones', () => { const notes = grammarNotes('Verb - Qal - Perfect - third person masculine singular'); expect(notes.map((n) => n.term)).toEqual(['Verb', 'Qal', 'Perfect', 'Third person singular']); expect(notes.find((n) => n.term === 'Perfect').meaning).toMatch(/complete/); expect(grammarNotes('Verb - Hiphil - Imperfect - third person masculine singular').find((n) => n.term === 'Hiphil').meaning).toMatch(/Causing/); }); test('Hebrew words with attached prefixes explain the prefix', () => { const notes = grammarNotes('Preposition-b | Noun - feminine singular'); expect(notes.map((n) => n.term)).toEqual(expect.arrayContaining(['Noun', 'Preposition-b'])); expect(notes.find((n) => n.term === 'Preposition-b').meaning).toMatch(/joined to the front/); }); test('nothing to explain gives an empty list', () => { expect(grammarNotes('')).toEqual([]); expect(grammarNotes(null)).toEqual([]); expect(grammarNotes('???')).toEqual([]); });