parseDocument.test.js (787B)
1 import assert from 'node:assert'; 2 import { readFileSync } from 'node:fs'; 3 import { dirname, join } from 'node:path'; 4 import { fileURLToPath } from 'node:url'; 5 import { describe, test } from 'node:test'; 6 import { parseOrgDocument } from './parseDocument.js'; 7 8 const __dirname = dirname(fileURLToPath(import.meta.url)); 9 10 describe('parseOrgDocument', () => { 11 test('extracts title keyword and headings', () => { 12 const content = readFileSync(join(__dirname, 'fixtures/headings-todo.org'), 'utf8'); 13 const doc = parseOrgDocument(content); 14 15 assert.equal(doc.title, 'Heading Sample'); 16 assert.ok(doc.headings.length >= 3); 17 assert.equal(doc.headings[0].title, 'Top level'); 18 assert.equal(doc.headings[1].level, 2); 19 assert.equal(doc.headings[1].todo, 'TODO'); 20 }); 21 });