Skip to content

docs: add JSDoc and tests for hooks#368

Merged
gka merged 3 commits into
svelteplot:mainfrom
ljodea:docs/jsdoc-hooks
Feb 14, 2026
Merged

docs: add JSDoc and tests for hooks#368
gka merged 3 commits into
svelteplot:mainfrom
ljodea:docs/jsdoc-hooks

Conversation

@ljodea

@ljodea ljodea commented Feb 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add JSDoc documentation to all exported functions and classes in plotDefaults.ts and usePlot.svelte.ts
  • Add 8 unit tests covering setPlotDefaults/getPlotDefaults (context merging, override behavior) and usePlot/setPlot (state access via Plot component context)
  • Test wrapper components follow the existing pattern from src/tests/plot.test.svelte

Test plan

  • All 8 new hook tests pass (pnpm run test:unit)
  • All 451 existing tests still pass
  • Prettier and ESLint pass (pnpm run lint)

🤖 Generated with Claude Code

Add JSDoc documentation to all exported functions and classes in
plotDefaults.ts and usePlot.svelte.ts. Add 8 unit tests covering
setPlotDefaults/getPlotDefaults (context merging, override behavior)
and usePlot/setPlot (state access via Plot component context).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@netlify

netlify Bot commented Feb 11, 2026

Copy link
Copy Markdown

Deploy Preview for svelteplot ready!

Name Link
🔨 Latest commit 191b78f
🔍 Latest deploy log https://app.netlify.com/projects/svelteplot/deploys/699094f1db85fa0008043bf3
😎 Deploy Preview https://deploy-preview-368--svelteplot.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds JSDoc documentation and comprehensive unit tests for the hooks functionality in SveltePlot. The changes improve code maintainability by documenting the public API of plotDefaults.ts and usePlot.svelte.ts, and add 8 new unit tests to verify the behavior of plot defaults context management and plot state access patterns.

Changes:

  • Added JSDoc comments to all exported functions in plotDefaults.ts and usePlot.svelte.ts, plus internal class methods
  • Added 4 test cases for setPlotDefaults/getPlotDefaults covering context merging and override behavior
  • Added 4 test cases for usePlot/setPlot covering state access via Plot component context

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib/hooks/plotDefaults.ts Added JSDoc documentation for setPlotDefaults and getPlotDefaults functions
src/lib/hooks/usePlot.svelte.ts Added JSDoc documentation for PlotState class, PublicPlotState class, and exported functions setPlot and usePlot
src/lib/hooks/plotDefaults.test.ts New test file with 4 test cases for plot defaults functionality
src/lib/hooks/plotDefaults.test.svelte Test wrapper component for testing plot defaults in Svelte context
src/lib/hooks/plotDefaultsNested.test.svelte Test wrapper component for testing nested plot defaults contexts
src/lib/hooks/usePlot.test.ts New test file with 4 test cases for usePlot hook functionality
src/lib/hooks/usePlot.test.svelte Test wrapper component wrapping Plot component for testing usePlot
src/lib/hooks/usePlotChild.test.svelte Child component that calls usePlot to expose plot state for testing

@@ -0,0 +1,52 @@
import { describe, it, expect } from 'vitest';

Copilot AI Feb 14, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test files are typically located in the src/tests/ directory rather than alongside source files. While the Vitest configuration will find these tests, consider moving all test files (plotDefaults.test.ts, plotDefaults.test.svelte, plotDefaultsNested.test.svelte, usePlot.test.ts, usePlot.test.svelte, usePlotChild.test.svelte) to src/tests/ for consistency with the established codebase pattern where all 451 existing tests reside in that directory.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

@gka gka merged commit ff5201f into svelteplot:main Feb 14, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants