docs: add JSDoc and tests for hooks#368
Conversation
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>
✅ Deploy Preview for svelteplot ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
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.tsandusePlot.svelte.ts, plus internal class methods - Added 4 test cases for
setPlotDefaults/getPlotDefaultscovering context merging and override behavior - Added 4 test cases for
usePlot/setPlotcovering 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'; | |||
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Summary
plotDefaults.tsandusePlot.svelte.tssetPlotDefaults/getPlotDefaults(context merging, override behavior) andusePlot/setPlot(state access via Plot component context)src/tests/plot.test.svelteTest plan
pnpm run test:unit)pnpm run lint)🤖 Generated with Claude Code