@@ -20,22 +20,22 @@ describe('Section Splitting', () => {
`;
- // Load components
- require('../core/section-manager.js');
+ // Load components
+ require('../core/section-manager.js');
- if (global.SectionManager) {
- sectionManager = new global.SectionManager();
- }
- });
+ if (global.SectionManager) {
+ sectionManager = new global.SectionManager();
+ }
+ });
- afterEach(() => {
- document.body.innerHTML = '';
- jest.clearAllMocks();
- });
+ afterEach(() => {
+ document.body.innerHTML = '';
+ jest.clearAllMocks();
+ });
- describe('Heading detection', () => {
- test('should detect new headings in content', () => {
- const textWithHeading = `
+ describe('Heading detection', () => {
+ test('should detect new headings in content', () => {
+ const textWithHeading = `
This is some content.
# New Heading
@@ -43,49 +43,49 @@ describe('Section Splitting', () => {
This should be a new section.
`;
- // Test heading detection with regex
- const lines = textWithHeading.trim().split('\n');
- const headingLine = lines.find(line => /^#+ /.test(line.trim()));
- expect(headingLine).toBeTruthy();
- expect(headingLine.trim()).toBe('# New Heading');
+ // Test heading detection with regex
+ const lines = textWithHeading.trim().split('\n');
+ const headingLine = lines.find(line => /^#+ /.test(line.trim()));
+ expect(headingLine).toBeTruthy();
+ expect(headingLine.trim()).toBe('# New Heading');
+ });
+
+ test('should identify different heading levels', () => {
+ const headingTests = [
+ { text: '# Heading 1', level: 1 },
+ { text: '## Heading 2', level: 2 },
+ { text: '### Heading 3', level: 3 },
+ { text: '#### Heading 4', level: 4 }
+ ];
+
+ headingTests.forEach(({ text, level }) => {
+ const match = text.match(/^(#+) /);
+ expect(match).toBeTruthy();
+ if (match) {
+ expect(match[1].length).toBe(level);
+ }
+ });
+ });
+
+ test('should distinguish headings from regular text', () => {
+ const testCases = [
+ { text: '# This is a heading', isHeading: true },
+ { text: 'This is not a heading', isHeading: false },
+ { text: 'Neither is this # hash in middle', isHeading: false },
+ { text: '## Another heading', isHeading: true }
+ ];
+
+ testCases.forEach(({ text, isHeading }) => {
+ const match = /^#+\s/.test(text.trim());
+ expect(match).toBe(isHeading);
+ });
+ });
});
- test('should identify different heading levels', () => {
- const headingTests = [
- { text: '# Heading 1', level: 1 },
- { text: '## Heading 2', level: 2 },
- { text: '### Heading 3', level: 3 },
- { text: '#### Heading 4', level: 4 }
- ];
-
- headingTests.forEach(({ text, level }) => {
- const match = text.match(/^(#+) /);
- expect(match).toBeTruthy();
- if (match) {
- expect(match[1].length).toBe(level);
- }
- });
- });
-
- test('should distinguish headings from regular text', () => {
- const testCases = [
- { text: '# This is a heading', isHeading: true },
- { text: 'This is not a heading', isHeading: false },
- { text: 'Neither is this # hash in middle', isHeading: false },
- { text: '## Another heading', isHeading: true }
- ];
-
- testCases.forEach(({ text, isHeading }) => {
- const match = /^#+\s/.test(text.trim());
- expect(match).toBe(isHeading);
- });
- });
- });
-
- describe('Section splitting logic', () => {
- test('should split content when heading is detected', () => {
- const originalContent = 'Original content without headings';
- const newContent = `
+ describe('Section splitting logic', () => {
+ test('should split content when heading is detected', () => {
+ const originalContent = 'Original content without headings';
+ const newContent = `
${originalContent}
# New Section
@@ -93,26 +93,26 @@ describe('Section Splitting', () => {
New section content
`;
- // Simulate section splitting logic
- const parts = newContent.split(/\n(?=#)/);
+ // Simulate section splitting logic
+ const parts = newContent.split(/\n(?=#)/);
- if (parts.length > 1) {
- expect(parts.length).toBeGreaterThan(1);
- expect(parts[0]).toContain('Original content');
- expect(parts[1]).toContain('# New Section');
- }
- });
+ if (parts.length > 1) {
+ expect(parts.length).toBeGreaterThan(1);
+ expect(parts[0]).toContain('Original content');
+ expect(parts[1]).toContain('# New Section');
+ }
+ });
- test('should preserve content when no headings are present', () => {
- const content = 'Just regular content without any headings';
- const parts = content.split(/\n(?=#)/);
+ test('should preserve content when no headings are present', () => {
+ const content = 'Just regular content without any headings';
+ const parts = content.split(/\n(?=#)/);
- expect(parts.length).toBe(1);
- expect(parts[0]).toBe(content);
- });
+ expect(parts.length).toBe(1);
+ expect(parts[0]).toBe(content);
+ });
- test('should handle multiple headings correctly', () => {
- const contentWithMultipleHeadings = `Initial content
+ test('should handle multiple headings correctly', () => {
+ const contentWithMultipleHeadings = `Initial content
# First Heading
First section content
@@ -123,48 +123,48 @@ Second section content
# Third Heading
Third section content`;
- // Split on lines that start with headings
- const parts = contentWithMultipleHeadings.split(/\n(?=#)/);
+ // Split on lines that start with headings
+ const parts = contentWithMultipleHeadings.split(/\n(?=#)/);
- // Should split into multiple sections
- expect(parts.length).toBeGreaterThanOrEqual(2);
+ // Should split into multiple sections
+ expect(parts.length).toBeGreaterThanOrEqual(2);
- // Find heading lines
- const headings = contentWithMultipleHeadings.match(/^#+.*$/gm);
- expect(headings).toBeTruthy();
- expect(headings.length).toBe(3);
- });
- });
-
- describe('SectionManager integration', () => {
- test('should have handleSectionSplit method', () => {
- if (!sectionManager) {
- console.warn('SectionManager not available, skipping test');
- return;
- }
-
- expect(typeof sectionManager.handleSectionSplit).toBe('function');
+ // Find heading lines
+ const headings = contentWithMultipleHeadings.match(/^#+.*$/gm);
+ expect(headings).toBeTruthy();
+ expect(headings.length).toBe(3);
+ });
});
- test('should maintain section state during splits', () => {
- if (!sectionManager) return;
+ describe('SectionManager integration', () => {
+ test('should have handleSectionSplit method', () => {
+ if (!sectionManager) {
+ console.warn('SectionManager not available, skipping test');
+ return;
+ }
- const originalSectionCount = document.querySelectorAll('.section').length;
+ expect(typeof sectionManager.handleSectionSplit).toBe('function');
+ });
- // Mock section splitting
- const mockNewSection = document.createElement('div');
- mockNewSection.className = 'section';
- mockNewSection.setAttribute('data-section-id', 'split-section');
+ test('should maintain section state during splits', () => {
+ if (!sectionManager) return;
- if (originalSectionCount > 0) {
- expect(originalSectionCount).toBeGreaterThan(0);
- }
+ const originalSectionCount = document.querySelectorAll('.section').length;
+
+ // Mock section splitting
+ const mockNewSection = document.createElement('div');
+ mockNewSection.className = 'section';
+ mockNewSection.setAttribute('data-section-id', 'split-section');
+
+ if (originalSectionCount > 0) {
+ expect(originalSectionCount).toBeGreaterThan(0);
+ }
+ });
});
- });
- describe('Dynamic section creation', () => {
- test('should create new section elements when splitting', () => {
- const sectionContent = `
+ describe('Dynamic section creation', () => {
+ test('should create new section elements when splitting', () => {
+ const sectionContent = `
Original content
# New Section Title
@@ -172,36 +172,36 @@ Third section content`;
New section content
`;
- // Simulate section creation
- const newSection = document.createElement('div');
- newSection.className = 'section';
- newSection.setAttribute('data-section-id', 'generated-section-id');
+ // Simulate section creation
+ const newSection = document.createElement('div');
+ newSection.className = 'section';
+ newSection.setAttribute('data-section-id', 'generated-section-id');
- const contentDiv = document.createElement('div');
- contentDiv.className = 'section-content';
- contentDiv.textContent = 'New section content';
+ const contentDiv = document.createElement('div');
+ contentDiv.className = 'section-content';
+ contentDiv.textContent = 'New section content';
- newSection.appendChild(contentDiv);
+ newSection.appendChild(contentDiv);
- expect(newSection.className).toBe('section');
- expect(newSection.getAttribute('data-section-id')).toBeTruthy();
- expect(newSection.querySelector('.section-content')).toBeTruthy();
- });
+ expect(newSection.className).toBe('section');
+ expect(newSection.getAttribute('data-section-id')).toBeTruthy();
+ expect(newSection.querySelector('.section-content')).toBeTruthy();
+ });
- test('should generate unique section IDs', () => {
- const headingText = 'My New Section';
+ test('should generate unique section IDs', () => {
+ const headingText = 'My New Section';
- // Simulate ID generation from heading
- const sectionId = headingText
- .toLowerCase()
- .replace(/[^a-z0-9]+/g, '-')
- .replace(/^-+|-+$/g, '');
+ // Simulate ID generation from heading
+ const sectionId = headingText
+ .toLowerCase()
+ .replace(/[^a-z0-9]+/g, '-')
+ .replace(/^-+|-+$/g, '');
- expect(sectionId).toBe('my-new-section');
- });
+ expect(sectionId).toBe('my-new-section');
+ });
- test('should preserve section hierarchy', () => {
- const hierarchicalContent = `
+ test('should preserve section hierarchy', () => {
+ const hierarchicalContent = `
# Main Section
Main content
@@ -212,20 +212,20 @@ Third section content`;
Sub-sub content
`;
- const headings = hierarchicalContent.match(/^#+.*$/gm);
+ const headings = hierarchicalContent.match(/^#+.*$/gm);
- if (headings) {
- expect(headings.length).toBe(3);
- expect(headings[0]).toMatch(/^# /);
- expect(headings[1]).toMatch(/^## /);
- expect(headings[2]).toMatch(/^### /);
- }
+ if (headings) {
+ expect(headings.length).toBe(3);
+ expect(headings[0]).toMatch(/^# /);
+ expect(headings[1]).toMatch(/^## /);
+ expect(headings[2]).toMatch(/^### /);
+ }
+ });
});
- });
- describe('Section splitting edge cases', () => {
- test('should handle empty headings gracefully', () => {
- const contentWithEmptyHeading = `
+ describe('Section splitting edge cases', () => {
+ test('should handle empty headings gracefully', () => {
+ const contentWithEmptyHeading = `
Content before
#
@@ -233,35 +233,35 @@ Third section content`;
Content after
`;
- const parts = contentWithEmptyHeading.split(/\n(?=#)/);
- expect(parts.length).toBeGreaterThanOrEqual(1);
- });
+ const parts = contentWithEmptyHeading.split(/\n(?=#)/);
+ expect(parts.length).toBeGreaterThanOrEqual(1);
+ });
- test('should handle headings at the start of content', () => {
- const contentStartingWithHeading = `# First Heading
+ test('should handle headings at the start of content', () => {
+ const contentStartingWithHeading = `# First Heading
Content for first section
# Second Heading
Content for second section
`;
- const parts = contentStartingWithHeading.split(/\n(?=#)/);
- expect(parts[0]).toContain('# First Heading');
- });
+ const parts = contentStartingWithHeading.split(/\n(?=#)/);
+ expect(parts[0]).toContain('# First Heading');
+ });
- test('should handle malformed headings', () => {
- const malformedHeadings = [
- '#NoSpace',
- '# ',
- '########## Too many hashes',
- 'Not a heading # at all'
- ];
+ test('should handle malformed headings', () => {
+ const malformedHeadings = [
+ '#NoSpace',
+ '# ',
+ '########## Too many hashes',
+ 'Not a heading # at all'
+ ];
- malformedHeadings.forEach(text => {
- const isValidHeading = /^#{1,6}\s+\S/.test(text);
- // Most should be invalid except properly formatted ones
- expect(typeof isValidHeading).toBe('boolean');
- });
+ malformedHeadings.forEach(text => {
+ const isValidHeading = /^#{1,6}\s+\S/.test(text);
+ // Most should be invalid except properly formatted ones
+ expect(typeof isValidHeading).toBe('boolean');
+ });
+ });
});
- });
-});
\ No newline at end of file
+});
diff --git a/js/tests/setup.js b/js/tests/setup.js
index 8f94a2b..3e06bcd 100644
--- a/js/tests/setup.js
+++ b/js/tests/setup.js
@@ -7,133 +7,133 @@
// Mock DOM globals that might be missing in JSDOM
global.ResizeObserver = jest.fn().mockImplementation(() => ({
- observe: jest.fn(),
- unobserve: jest.fn(),
- disconnect: jest.fn(),
+ observe: jest.fn(),
+ unobserve: jest.fn(),
+ disconnect: jest.fn()
}));
global.IntersectionObserver = jest.fn().mockImplementation(() => ({
- observe: jest.fn(),
- unobserve: jest.fn(),
- disconnect: jest.fn(),
+ observe: jest.fn(),
+ unobserve: jest.fn(),
+ disconnect: jest.fn()
}));
// Mock window.matchMedia
Object.defineProperty(window, 'matchMedia', {
- writable: true,
- value: jest.fn().mockImplementation(query => ({
- matches: false,
- media: query,
- onchange: null,
- addListener: jest.fn(), // deprecated
- removeListener: jest.fn(), // deprecated
- addEventListener: jest.fn(),
- removeEventListener: jest.fn(),
- dispatchEvent: jest.fn(),
- })),
+ writable: true,
+ value: jest.fn().mockImplementation(query => ({
+ matches: false,
+ media: query,
+ onchange: null,
+ addListener: jest.fn(), // deprecated
+ removeListener: jest.fn(), // deprecated
+ addEventListener: jest.fn(),
+ removeEventListener: jest.fn(),
+ dispatchEvent: jest.fn()
+ }))
});
// Mock local storage
const localStorageMock = {
- getItem: jest.fn(),
- setItem: jest.fn(),
- removeItem: jest.fn(),
- clear: jest.fn(),
+ getItem: jest.fn(),
+ setItem: jest.fn(),
+ removeItem: jest.fn(),
+ clear: jest.fn()
};
global.localStorage = localStorageMock;
// Mock session storage
const sessionStorageMock = {
- getItem: jest.fn(),
- setItem: jest.fn(),
- removeItem: jest.fn(),
- clear: jest.fn(),
+ getItem: jest.fn(),
+ setItem: jest.fn(),
+ removeItem: jest.fn(),
+ clear: jest.fn()
};
global.sessionStorage = sessionStorageMock;
// Global test utilities
global.testUtils = {
- /**
+ /**
* Create a mock DOM element with specified tag and attributes
*/
- createElement: (tag, attributes = {}) => {
- const element = document.createElement(tag);
- Object.entries(attributes).forEach(([key, value]) => {
- element.setAttribute(key, value);
- });
- return element;
- },
+ createElement: (tag, attributes = {}) => {
+ const element = document.createElement(tag);
+ Object.entries(attributes).forEach(([key, value]) => {
+ element.setAttribute(key, value);
+ });
+ return element;
+ },
- /**
+ /**
* Create a test markdown content div
*/
- createMarkdownContent: (content = '# Test Content') => {
- const div = document.createElement('div');
- div.id = 'markdown-content';
- div.innerHTML = content;
- return div;
- },
+ createMarkdownContent: (content = '# Test Content') => {
+ const div = document.createElement('div');
+ div.id = 'markdown-content';
+ div.innerHTML = content;
+ return div;
+ },
- /**
+ /**
* Wait for next tick (useful for async operations)
*/
- nextTick: () => new Promise(resolve => setTimeout(resolve, 0)),
+ nextTick: () => new Promise(resolve => setTimeout(resolve, 0)),
- /**
+ /**
* Simulate user interaction events
*/
- simulateEvent: (element, eventType, eventProperties = {}) => {
- const event = new Event(eventType, { bubbles: true, ...eventProperties });
- Object.entries(eventProperties).forEach(([key, value]) => {
- event[key] = value;
- });
- element.dispatchEvent(event);
- return event;
- },
+ simulateEvent: (element, eventType, eventProperties = {}) => {
+ const event = new Event(eventType, { bubbles: true, ...eventProperties });
+ Object.entries(eventProperties).forEach(([key, value]) => {
+ event[key] = value;
+ });
+ element.dispatchEvent(event);
+ return event;
+ },
- /**
+ /**
* Clean up DOM after each test
*/
- cleanupDOM: () => {
- document.body.innerHTML = '';
- document.head.innerHTML = '';
- }
+ cleanupDOM: () => {
+ document.body.innerHTML = '';
+ document.head.innerHTML = '';
+ }
};
// Setup and teardown
beforeEach(() => {
- // Reset mocks
- jest.clearAllMocks();
+ // Reset mocks
+ jest.clearAllMocks();
- // Reset localStorage/sessionStorage
- localStorageMock.getItem.mockClear();
- localStorageMock.setItem.mockClear();
- localStorageMock.removeItem.mockClear();
- localStorageMock.clear.mockClear();
+ // Reset localStorage/sessionStorage
+ localStorageMock.getItem.mockClear();
+ localStorageMock.setItem.mockClear();
+ localStorageMock.removeItem.mockClear();
+ localStorageMock.clear.mockClear();
- sessionStorageMock.getItem.mockClear();
- sessionStorageMock.setItem.mockClear();
- sessionStorageMock.removeItem.mockClear();
- sessionStorageMock.clear.mockClear();
+ sessionStorageMock.getItem.mockClear();
+ sessionStorageMock.setItem.mockClear();
+ sessionStorageMock.removeItem.mockClear();
+ sessionStorageMock.clear.mockClear();
});
afterEach(() => {
- // Clean up DOM
- global.testUtils.cleanupDOM();
+ // Clean up DOM
+ global.testUtils.cleanupDOM();
- // Clean up any timers
- jest.runOnlyPendingTimers();
- jest.useRealTimers();
+ // Clean up any timers
+ jest.runOnlyPendingTimers();
+ jest.useRealTimers();
});
// Console helpers for test debugging
global.console = {
- ...console,
- // Keep these methods for test debugging
- log: console.log,
- warn: console.warn,
- error: console.error,
- // Mock these to avoid noise in tests
- info: jest.fn(),
- debug: jest.fn(),
-};
\ No newline at end of file
+ ...console,
+ // Keep these methods for test debugging
+ log: console.log,
+ warn: console.warn,
+ error: console.error,
+ // Mock these to avoid noise in tests
+ info: jest.fn(),
+ debug: jest.fn()
+};
diff --git a/js/tests/test-component-integration.js b/js/tests/test-component-integration.js
index 2107dc9..c8d2bb1 100644
--- a/js/tests/test-component-integration.js
+++ b/js/tests/test-component-integration.js
@@ -12,7 +12,6 @@ const RefactorTestRunner = require('./refactor-test-runner.js');
const runner = new RefactorTestRunner();
runner.describe('Component Integration Tests', () => {
-
runner.it('should load all extracted components', () => {
try {
// Load extracted components
@@ -30,7 +29,6 @@ runner.describe('Component Integration Tests', () => {
global.ExtractedDOMRenderer = domModule.DOMRenderer;
global.ExtractedFloatingMenu = domModule.FloatingMenu;
global.ExtractedEditState = sectionModule.EditState;
-
} catch (error) {
throw new Error(`Failed to load extracted components: ${error.message}`);
}
@@ -62,7 +60,6 @@ Content for second subsection.`;
const sections = sectionManager.createSectionsFromMarkdown(testMarkdown);
-
// Verify sections were created
// Expected: heading+paragraph, heading+paragraph, image, heading+paragraph = 4 sections
runner.expect(sections.length).toBe(4);
@@ -297,12 +294,11 @@ console.log('test');
const sections = sectionManager.createSectionsFromMarkdown(testMarkdown);
-
// Verify type detection - adjusted for actual parsing behavior
// Expected: heading+paragraph, image, code = 3 sections
runner.expect(sections[0].type).toBe('heading'); // Combined heading+paragraph
- runner.expect(sections[1].type).toBe('image'); // Image section
- runner.expect(sections[2].type).toBe('code'); // Code section
+ runner.expect(sections[1].type).toBe('image'); // Image section
+ runner.expect(sections[2].type).toBe('code'); // Code section
// Verify image detection
runner.expect(sections[1].isImage()).toBeTruthy(); // Image is now at index 1
@@ -518,4 +514,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
Component integration tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-debugpanel-extraction.js b/js/tests/test-debugpanel-extraction.js
index 5dca6ca..28beeaa 100644
--- a/js/tests/test-debugpanel-extraction.js
+++ b/js/tests/test-debugpanel-extraction.js
@@ -25,7 +25,6 @@ const EXPECTED_DEBUGPANEL_API = [
];
runner.describe('DebugPanel Component Extraction', () => {
-
runner.it('should define expected API methods', () => {
const expectedMethods = EXPECTED_DEBUGPANEL_API;
runner.expect(expectedMethods.length).toBe(9);
@@ -188,4 +187,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
DebugPanel extraction tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-debugpanel-integration.js b/js/tests/test-debugpanel-integration.js
index af03ff8..07e7d02 100644
--- a/js/tests/test-debugpanel-integration.js
+++ b/js/tests/test-debugpanel-integration.js
@@ -12,7 +12,6 @@ const RefactorTestRunner = require('./refactor-test-runner.js');
const runner = new RefactorTestRunner();
runner.describe('DebugPanel Integration Tests', () => {
-
runner.it('should load all extracted components including DebugPanel', () => {
try {
// Load extracted components
@@ -28,7 +27,6 @@ runner.describe('DebugPanel Integration Tests', () => {
global.ExtractedSectionManager = sectionModule.SectionManager;
global.ExtractedDOMRenderer = domModule.DOMRenderer;
global.ExtractedDebugPanel = debugModule.DebugPanel;
-
} catch (error) {
throw new Error(`Failed to load extracted components: ${error.message}`);
}
@@ -207,4 +205,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
DebugPanel integration tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-document-navigator.js b/js/tests/test-document-navigator.js
index e6a79f9..306e352 100644
--- a/js/tests/test-document-navigator.js
+++ b/js/tests/test-document-navigator.js
@@ -84,13 +84,13 @@ class DocumentNavigatorTestRunner {
}
printSummary() {
- console.log(`\nš Test Results:`);
+ console.log('\nš Test Results:');
console.log(` Passed: ${this.results.passed}`);
console.log(` Failed: ${this.results.failed}`);
console.log(` Total: ${this.results.total}`);
if (this.results.failed === 0) {
- console.log(`\nš All tests passed!`);
+ console.log('\nš All tests passed!');
} else {
console.log(`\nā ${this.results.failed} test(s) failed.`);
}
@@ -429,4 +429,4 @@ window.runDocumentNavigatorTests = () => runner.run();
console.log('š DocumentNavigator TDD Test Suite loaded. Run with: runDocumentNavigatorTests()');
-export { runner };
\ No newline at end of file
+export { runner };
diff --git a/js/tests/test-documentcontrols-extraction.js b/js/tests/test-documentcontrols-extraction.js
index 2d5607c..6a938ff 100644
--- a/js/tests/test-documentcontrols-extraction.js
+++ b/js/tests/test-documentcontrols-extraction.js
@@ -26,7 +26,6 @@ const EXPECTED_DOCUMENTCONTROLS_API = [
];
runner.describe('DocumentControls Component Extraction', () => {
-
runner.it('should define expected API methods', () => {
const expectedMethods = EXPECTED_DOCUMENTCONTROLS_API;
runner.expect(expectedMethods.length).toBe(10);
@@ -215,4 +214,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
DocumentControls extraction tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-domrenderer-extraction.js b/js/tests/test-domrenderer-extraction.js
index e8aadc0..c91acf1 100644
--- a/js/tests/test-domrenderer-extraction.js
+++ b/js/tests/test-domrenderer-extraction.js
@@ -28,7 +28,6 @@ const EXPECTED_DOMRENDERER_API = [
];
runner.describe('DOMRenderer Component Extraction', () => {
-
runner.it('should define expected API methods', () => {
const expectedMethods = EXPECTED_DOMRENDERER_API;
runner.expect(expectedMethods.length).toBe(11);
@@ -42,7 +41,7 @@ runner.describe('DOMRenderer Component Extraction', () => {
delete require.cache[require.resolve('/home/worsch/markitect_project/markitect/static/editor.js')];
try {
- const editorModule = require('/home/worsch/markitect_project/markitect/static/editor.js');
+ const editorModule = require('../../../../../../../../home/worsch/markitect_project/markitect/static/editor.js');
runner.expect(editorModule.DOMRenderer).toBeTruthy();
// Set global for other tests
global.DOMRenderer = editorModule.DOMRenderer;
@@ -209,4 +208,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
DOMRenderer extraction tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-environment.test.js b/js/tests/test-environment.test.js
index c35e13b..523069b 100644
--- a/js/tests/test-environment.test.js
+++ b/js/tests/test-environment.test.js
@@ -21,4 +21,4 @@ describe('Test Environment', () => {
expect(contentEl).toBeDefined();
expect(contentEl.tagName).toBe('DIV');
});
-});
\ No newline at end of file
+});
diff --git a/js/tests/test-extracted-domrenderer.js b/js/tests/test-extracted-domrenderer.js
index d0a8990..c4b3968 100644
--- a/js/tests/test-extracted-domrenderer.js
+++ b/js/tests/test-extracted-domrenderer.js
@@ -12,7 +12,6 @@ const RefactorTestRunner = require('./refactor-test-runner.js');
const runner = new RefactorTestRunner();
runner.describe('Extracted DOMRenderer Component', () => {
-
runner.it('should load extracted DOMRenderer component', () => {
// Load the extracted component
delete require.cache[require.resolve('../components/dom-renderer.js')];
@@ -214,7 +213,7 @@ runner.describe('Extracted DOMRenderer Component', () => {
// Comparative test - verify extracted component behaves similarly to original
runner.it('should behave similarly to original monolithic component', () => {
// Load both components
- const originalModule = require('/home/worsch/markitect_project/markitect/static/editor.js');
+ const originalModule = require('../../../../../../../../home/worsch/markitect_project/markitect/static/editor.js');
const extractedModule = require('../components/dom-renderer.js');
const sectionModule = require('../core/section-manager.js');
@@ -268,4 +267,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
Extracted DOMRenderer tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-extracted-section-manager.js b/js/tests/test-extracted-section-manager.js
index 0eb51d0..7365c22 100644
--- a/js/tests/test-extracted-section-manager.js
+++ b/js/tests/test-extracted-section-manager.js
@@ -12,7 +12,6 @@ const RefactorTestRunner = require('./refactor-test-runner.js');
const runner = new RefactorTestRunner();
runner.describe('Extracted SectionManager Component', () => {
-
runner.it('should load extracted SectionManager component', () => {
// Load the extracted component
delete require.cache[require.resolve('../core/section-manager.js')];
@@ -47,7 +46,7 @@ runner.describe('Extracted SectionManager Component', () => {
const SectionManager = global.ExtractedSectionManager;
const manager = new SectionManager();
- const testMarkdown = `# Heading 1\nContent 1\n\n## Heading 2\nContent 2`;
+ const testMarkdown = '# Heading 1\nContent 1\n\n## Heading 2\nContent 2';
const sections = manager.createSectionsFromMarkdown(testMarkdown);
runner.expect(Array.isArray(sections)).toBeTruthy();
@@ -170,7 +169,7 @@ runner.describe('Extracted SectionManager Component', () => {
// Comparative test - verify extracted component behaves identically to original
runner.it('should behave identically to original monolithic component', () => {
// Load both components
- const originalModule = require('/home/worsch/markitect_project/markitect/static/editor.js');
+ const originalModule = require('../../../../../../../../home/worsch/markitect_project/markitect/static/editor.js');
const extractedModule = require('../core/section-manager.js');
const originalManager = new originalModule.SectionManager();
@@ -223,4 +222,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
Extracted SectionManager tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-full-integration.js b/js/tests/test-full-integration.js
index 3edb0ce..7a3fe58 100644
--- a/js/tests/test-full-integration.js
+++ b/js/tests/test-full-integration.js
@@ -12,7 +12,6 @@ const RefactorTestRunner = require('./refactor-test-runner.js');
const runner = new RefactorTestRunner();
runner.describe('Full Component Integration Tests', () => {
-
runner.it('should load all extracted components', () => {
try {
// Load all extracted components
@@ -31,7 +30,6 @@ runner.describe('Full Component Integration Tests', () => {
global.ExtractedDOMRenderer = domModule.DOMRenderer;
global.ExtractedDebugPanel = debugModule.DebugPanel;
global.ExtractedDocumentControls = controlsModule.DocumentControls;
-
} catch (error) {
throw new Error(`Failed to load extracted components: ${error.message}`);
}
@@ -163,7 +161,7 @@ More detailed content here.`;
documentControls.create();
// Setup comprehensive event handling
- let eventLog = [];
+ const eventLog = [];
sectionManager.on('sections-created', (data) => {
eventLog.push(`sections-created: ${data.count} sections`);
@@ -302,4 +300,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
Full integration tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-real-user-functionality.js b/js/tests/test-real-user-functionality.js
index 3d7fdde..ce79c47 100644
--- a/js/tests/test-real-user-functionality.js
+++ b/js/tests/test-real-user-functionality.js
@@ -12,7 +12,6 @@ const RefactorTestRunner = require('./refactor-test-runner.js');
const runner = new RefactorTestRunner();
runner.describe('Real User Functionality Tests', () => {
-
runner.it('should allow users to edit content and see changes in DOM', () => {
// Load all extracted components
const sectionModule = require('../core/section-manager.js');
@@ -40,7 +39,7 @@ runner.describe('Real User Functionality Tests', () => {
documentControls.create();
// Create sections from test markdown
- const testMarkdown = `# Original Title\nOriginal content that should be editable.`;
+ const testMarkdown = '# Original Title\nOriginal content that should be editable.';
const sections = sectionManager.createSectionsFromMarkdown(testMarkdown);
domRenderer.renderAllSections(sections);
@@ -113,7 +112,7 @@ runner.describe('Real User Functionality Tests', () => {
documentControls.create();
// Create and modify content
- const testMarkdown = `# Test Section\nOriginal content for reset test.`;
+ const testMarkdown = '# Test Section\nOriginal content for reset test.';
const sections = sectionManager.createSectionsFromMarkdown(testMarkdown);
domRenderer.renderAllSections(sections);
@@ -161,7 +160,7 @@ runner.describe('Real User Functionality Tests', () => {
const sectionManager = new SectionManager();
const domRenderer = new DOMRenderer(sectionManager, container);
- const testMarkdown = `# Cancel Test\nContent that should remain unchanged.`;
+ const testMarkdown = '# Cancel Test\nContent that should remain unchanged.';
const sections = sectionManager.createSectionsFromMarkdown(testMarkdown);
domRenderer.renderAllSections(sections);
@@ -282,4 +281,4 @@ if (require.main === module) {
console.log('ā
Real user functionality tests completed');
console.log('These tests validate what users actually experience, not just internal APIs');
});
-}
\ No newline at end of file
+}
diff --git a/js/tests/test-section-manager-extraction.js b/js/tests/test-section-manager-extraction.js
index 1eecce5..abdb7e5 100644
--- a/js/tests/test-section-manager-extraction.js
+++ b/js/tests/test-section-manager-extraction.js
@@ -31,7 +31,6 @@ const EXPECTED_SECTION_MANAGER_API = [
];
runner.describe('SectionManager Component Extraction', () => {
-
runner.it('should define expected API methods', () => {
// This test defines what we expect from the extracted SectionManager
const expectedMethods = EXPECTED_SECTION_MANAGER_API;
@@ -46,7 +45,7 @@ runner.describe('SectionManager Component Extraction', () => {
delete require.cache[require.resolve('/home/worsch/markitect_project/markitect/static/editor.js')];
try {
- const editorModule = require('/home/worsch/markitect_project/markitect/static/editor.js');
+ const editorModule = require('../../../../../../../../home/worsch/markitect_project/markitect/static/editor.js');
runner.expect(editorModule.SectionManager).toBeTruthy();
// Set global for other tests
global.SectionManager = editorModule.SectionManager;
@@ -69,7 +68,7 @@ runner.describe('SectionManager Component Extraction', () => {
const SectionManager = global.SectionManager;
const manager = new SectionManager();
- const testMarkdown = `# Heading 1\nContent 1\n\n## Heading 2\nContent 2`;
+ const testMarkdown = '# Heading 1\nContent 1\n\n## Heading 2\nContent 2';
const sections = manager.createSectionsFromMarkdown(testMarkdown);
runner.expect(Array.isArray(sections)).toBeTruthy();
@@ -193,4 +192,4 @@ if (require.main === module) {
runner.run().then(() => {
console.log('ā
SectionManager extraction tests completed');
});
-}
\ No newline at end of file
+}
diff --git a/js/utils/html-generator.js b/js/utils/html-generator.js
index a4e0b08..14b305c 100644
--- a/js/utils/html-generator.js
+++ b/js/utils/html-generator.js
@@ -23,9 +23,9 @@ class HTMLGenerator {
title: options.title || 'TestDrive-JSUI Editor',
description: options.description || 'Interactive markdown editor',
markdown: options.markdown || '# Welcome\n\nStart editing...',
- mode: options.mode || 'edit', // 'edit' or 'view'
+ mode: options.mode || 'edit', // 'edit' or 'view'
theme: options.theme || 'github',
- standalone: options.standalone !== false, // default true
+ standalone: options.standalone !== false, // default true
controls: {
editControl: options.controls?.editControl !== false,
statusControl: options.controls?.statusControl !== false,
@@ -34,8 +34,8 @@ class HTMLGenerator {
},
shortcuts: options.shortcuts !== false,
autosave: options.autosave || false,
- baseUrl: options.baseUrl || '_jsui', // For external mode
- includeMarkedJS: options.includeMarkedJS !== false // Include marked.js CDN
+ baseUrl: options.baseUrl || '_jsui', // For external mode
+ includeMarkedJS: options.includeMarkedJS !== false // Include marked.js CDN
};
}
diff --git a/js/widgets/base/UIWidget.js b/js/widgets/base/UIWidget.js
index c889d0d..0133b33 100644
--- a/js/widgets/base/UIWidget.js
+++ b/js/widgets/base/UIWidget.js
@@ -212,4 +212,4 @@ export class UIWidget extends Widget {
enableAnimations: true
};
}
-}
\ No newline at end of file
+}
diff --git a/js/widgets/base/Widget.js b/js/widgets/base/Widget.js
index 1c284cf..d80d481 100644
--- a/js/widgets/base/Widget.js
+++ b/js/widgets/base/Widget.js
@@ -138,4 +138,4 @@ export class Widget extends EventTarget {
return element;
}
-}
\ No newline at end of file
+}
diff --git a/js/widgets/navigation/DocumentNavigator.js b/js/widgets/navigation/DocumentNavigator.js
index d25e058..742ed3c 100644
--- a/js/widgets/navigation/DocumentNavigator.js
+++ b/js/widgets/navigation/DocumentNavigator.js
@@ -32,15 +32,15 @@ export class DocumentNavigator extends UIWidget {
getDefaultConfig() {
return {
...super.getDefaultConfig(),
- position: 'left', // 'left' or 'right'
- collapsed: true, // Start collapsed
- autoHide: true, // Hide on mobile
- maxHeadingLevel: 3, // H1, H2, H3
- enableScrollSpy: true, // Highlight current section
- smoothScroll: true, // Smooth scroll behavior
- animationDuration: 300, // Animation timing
- minHeadings: 2, // Min headings to show navigator
- theme: 'default', // Theme support
+ position: 'left', // 'left' or 'right'
+ collapsed: true, // Start collapsed
+ autoHide: true, // Hide on mobile
+ maxHeadingLevel: 3, // H1, H2, H3
+ enableScrollSpy: true, // Highlight current section
+ smoothScroll: true, // Smooth scroll behavior
+ animationDuration: 300, // Animation timing
+ minHeadings: 2, // Min headings to show navigator
+ theme: 'default', // Theme support
// Styling options
width: '280px',
@@ -89,7 +89,7 @@ export class DocumentNavigator extends UIWidget {
className: 'document-navigator markitect-widget',
attributes: {
'aria-label': this.config.ariaLabel,
- 'role': 'navigation'
+ role: 'navigation'
},
style: this.getNavigatorStyle()
});
@@ -130,7 +130,7 @@ export class DocumentNavigator extends UIWidget {
this.toggleButton = this.createElement('button', {
className: 'navigator-toggle',
attributes: {
- 'type': 'button',
+ type: 'button',
'aria-label': this.isCollapsed ? 'Expand navigation' : 'Collapse navigation',
'aria-expanded': !this.isCollapsed
},
@@ -236,11 +236,11 @@ export class DocumentNavigator extends UIWidget {
className: 'navigator-link',
textContent: item.text,
attributes: {
- 'href': `#${item.id}`,
+ href: `#${item.id}`,
'data-target': item.id,
'data-level': item.level,
- 'role': 'button',
- 'tabindex': '0'
+ role: 'button',
+ tabindex: '0'
},
style: {
display: 'block',
@@ -622,4 +622,4 @@ export class DocumentNavigator extends UIWidget {
await super.destroy();
}
-}
\ No newline at end of file
+}
diff --git a/src/components/ui-edit-button/ui-edit-button.js b/src/components/ui-edit-button/ui-edit-button.js
index c4a609f..d99ce1a 100644
--- a/src/components/ui-edit-button/ui-edit-button.js
+++ b/src/components/ui-edit-button/ui-edit-button.js
@@ -1,7 +1,7 @@
-import { LitElement, html, css } from "lit";
+import { LitElement, html, css } from 'lit';
export class UiEditButton extends LitElement {
- static styles = css`
+ static styles = css`
button {
position: fixed;
top: 50%;
@@ -20,13 +20,13 @@ export class UiEditButton extends LitElement {
}
`;
- render() {
- return html`
`;
- }
+ render() {
+ return html`
`;
+ }
- _onClick() {
- alert("Edit button clicked!");
- }
+ _onClick() {
+ alert('Edit button clicked!');
+ }
}
-customElements.define("ui-edit-button", UiEditButton);
+customElements.define('ui-edit-button', UiEditButton);
diff --git a/src/components/ui-edit-button/ui-edit-button.stories.js b/src/components/ui-edit-button/ui-edit-button.stories.js
index c002a96..02c2de2 100644
--- a/src/components/ui-edit-button/ui-edit-button.stories.js
+++ b/src/components/ui-edit-button/ui-edit-button.stories.js
@@ -1,7 +1,7 @@
-import "./ui-edit-button.js";
+import './ui-edit-button.js';
export default {
- title: "UI/Edit Button",
+ title: 'UI/Edit Button'
};
-export const Default = () => `
`;
+export const Default = () => '
';
diff --git a/src/components/ui-edit-button/ui-edit-button.test.js b/src/components/ui-edit-button/ui-edit-button.test.js
index 4f50e03..1df6d91 100644
--- a/src/components/ui-edit-button/ui-edit-button.test.js
+++ b/src/components/ui-edit-button/ui-edit-button.test.js
@@ -1,24 +1,24 @@
-import "../ui-edit-button/ui-edit-button.js";
+import '../ui-edit-button/ui-edit-button.js';
-describe("
", () => {
- it("renders a button element", () => {
- const el = document.createElement("ui-edit-button");
- document.body.appendChild(el);
- const button = el.shadowRoot.querySelector("button");
- expect(button).to.exist;
- expect(button.textContent).to.include("Edit");
- });
+describe('', () => {
+ it('renders a button element', () => {
+ const el = document.createElement('ui-edit-button');
+ document.body.appendChild(el);
+ const button = el.shadowRoot.querySelector('button');
+ expect(button).to.exist;
+ expect(button.textContent).to.include('Edit');
+ });
- it("triggers a click handler", () => {
- const el = document.createElement("ui-edit-button");
- document.body.appendChild(el);
+ it('triggers a click handler', () => {
+ const el = document.createElement('ui-edit-button');
+ document.body.appendChild(el);
- let clicked = false;
- el._onClick = () => (clicked = true);
+ let clicked = false;
+ el._onClick = () => (clicked = true);
- const button = el.shadowRoot.querySelector("button");
- button.click();
+ const button = el.shadowRoot.querySelector('button');
+ button.click();
- expect(clicked).to.be.true;
- });
+ expect(clicked).to.be.true;
+ });
});
diff --git a/src/index.js b/src/index.js
index 6ac0896..0522e76 100644
--- a/src/index.js
+++ b/src/index.js
@@ -48,8 +48,8 @@ import '../js/testdrive-jsui.js';
// Get the TestDriveJSUI from window (set by testdrive-jsui.js)
// In UMD build, this will be available globally
-const TestDriveJSUI = (typeof window !== 'undefined' && window.TestDriveJSUI)
- || (typeof global !== 'undefined' && global.TestDriveJSUI);
+const TestDriveJSUI = (typeof window !== 'undefined' && window.TestDriveJSUI) ||
+ (typeof global !== 'undefined' && global.TestDriveJSUI);
// Export for ES modules and CommonJS
export default TestDriveJSUI;