Files
markitect-main/history/2025/251114-javascript-dev-tests/test_get_all_sections.js
tegwick 77415bfad7
Some checks failed
Test Suite / unit-tests (3.11) (push) Has been cancelled
Test Suite / unit-tests (3.12) (push) Has been cancelled
Test Suite / integration-tests (push) Has been cancelled
Test Suite / e2e-tests (push) Has been cancelled
Test Suite / performance-tests (push) Has been cancelled
Test Suite / code-quality (push) Has been cancelled
Test Suite / security-scan (push) Has been cancelled
Test Suite / test-summary (push) Has been cancelled
chore: cleanup of history file
2026-01-05 22:01:04 +01:00

82 lines
2.9 KiB
JavaScript
Executable File

#!/usr/bin/env node
/**
* TDD Tests for getAllSections Method Recovery
*/
const { TestRunner } = require('./test_runner.js');
const runner = new TestRunner();
// Test getAllSections functionality
runner.describe('SectionManager getAllSections method', () => {
runner.it('should have getAllSections method in SectionManager', async () => {
// Load editor
delete require.cache[require.resolve('/home/worsch/markitect_project/markitect/static/editor.js')];
require('/home/worsch/markitect_project/markitect/static/editor.js');
if (global.SectionManager) {
const manager = new global.SectionManager();
const hasGetAllSections = typeof manager.getAllSections === 'function';
runner.expect(hasGetAllSections).toBeTruthy();
}
});
runner.it('should return array of all sections', async () => {
if (global.SectionManager) {
const manager = new global.SectionManager();
// Create some test sections
const sections = manager.createSectionsFromMarkdown('# Test\n\nContent\n\n## Another\n\nMore content');
// getAllSections should return an array
const allSections = manager.getAllSections();
runner.expect(Array.isArray(allSections)).toBeTruthy();
runner.expect(allSections.length).toBe(sections.length);
}
});
runner.it('should return all sections from the sections Map', async () => {
if (global.SectionManager) {
const manager = new global.SectionManager();
// Create sections
manager.createSectionsFromMarkdown('# Test\n\nContent');
const allSections = manager.getAllSections();
const mapSize = manager.sections.size;
runner.expect(allSections.length).toBe(mapSize);
}
});
runner.it('should return sections with proper properties', async () => {
if (global.SectionManager) {
const manager = new global.SectionManager();
// Create sections
manager.createSectionsFromMarkdown('# Test\n\nContent');
const allSections = manager.getAllSections();
if (allSections.length > 0) {
const firstSection = allSections[0];
runner.expect(firstSection.id).toBeTruthy();
runner.expect(firstSection.currentMarkdown).toBeTruthy();
runner.expect(typeof firstSection.hasChanges).toBe('function');
runner.expect(typeof firstSection.isEditing).toBe('function');
runner.expect(typeof firstSection.getStatus).toBe('function');
}
}
});
});
// Run the tests
if (require.main === module) {
console.log('📊 Running TDD Tests for getAllSections Method Recovery');
runner.run().then(() => {
console.log('✅ Test run complete - now implement getAllSections!');
});
}
module.exports = runner;