Skip to content

test: add unit tests for MarkdownEditorComponent #70

Description

@corvid-agent

Summary

MarkdownEditorComponent has a spec.md (added in #68) but no unit test file. The component wraps CodeMirror 6 with non-trivial lifecycle management including a suppressUpdate feedback-loop prevention mechanism that should be verified.

Recommended test cases

Scenario Description
Initial render Component creates, CodeMirror EditorView is instantiated
Content change emission User typing emits contentChange with full document text
External content sync Changing the content input dispatches a transaction to update the editor
Identical content no-op Setting same content value does not dispatch a transaction
Suppress flag After user edit, the next effect run skips dispatch (prevents feedback loop)
Destroy cleanup ngOnDestroy calls view.destroy()

Notes

  • CodeMirror requires a DOM host element; tests will need careful setup with jsdom
  • May need to spy on EditorView constructor and dispatch method
  • Consider whether fake-indexeddb (already in devDependencies) is relevant here

Files

  • Source: src/app/components/markdown-editor/markdown-editor.ts
  • Spec: specs/components/markdown-editor.spec.md
  • Test (to create): src/app/components/markdown-editor/markdown-editor.spec.ts

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions