Skip to content

test: add PriceSparkline component and unit tests for data point rendering - #576

Merged
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
wagmiiii:test/issue-572-price-sparkline
Jul 25, 2026
Merged

test: add PriceSparkline component and unit tests for data point rendering#576
Chucks1093 merged 1 commit into
accesslayerorg:devfrom
wagmiiii:test/issue-572-price-sparkline

Conversation

@wagmiiii

Copy link
Copy Markdown
Contributor

Summary

Adds the missing PriceSparkline SVG component and comprehensive unit tests for rendering the correct number of data points, edge cases, and line color.

What changed

  • src/components/common/PriceSparkline.tsx — New component that accepts a dataPoints: number[] prop and renders an SVG <path> polyline. Handles 7+ points (full line), 1 point (circle dot, no path), and 0 points (returns null).
  • src/components/common/__tests__/PriceSparkline.test.tsx — Co-located tests covering all acceptance criteria.

Key design decisions

  • Component is standalone and agnostic about data source — accepts dataPoints directly rather than coupling to the Course model (which has no priceHistory field). Integration into CreatorCard is a follow-up.
  • Uses emerald-400 (#34d399) for the positive line color, matching the design system already used in RecentActivityBadge, Change24hBadge, etc.
  • For 0 data points → returns null so callers see nothing. For 1 data point → renders an SVG with a dot (no line path), which satisfies "no error" without visual breakage.

Acceptance criteria checklist

  • 7 data points produce a rendered <path> element
  • 1 data point renders without throwing (no line path, dot only)
  • 0 data points renders nothing (empty container)
  • Green line colour (#34d399) applied when last value > first value

Test output

✓ src/components/common/__tests__/PriceSparkline.test.tsx (4 tests) 79ms
  Tests  4 passed (4)

Follow-ups

  • Wire PriceSparkline into CreatorCard.tsx when the API provides priceHistory data
  • Add a red/rose line color for negative trends (not in scope of this issue)

Security note

No secrets, user input, or auth tokens are involved. The component only renders static SVG from numeric data.

Closes #572

…ering

- Create PriceSparkline component rendering SVG path from dataPoints array
- Handle 7, 1, and 0 data point edge cases safely
- Apply emerald-400 line color when last value > first value
- Co-locate tests following existing __tests__/ convention

Closes accesslayerorg#572
@drips-wave

drips-wave Bot commented Jul 25, 2026

Copy link
Copy Markdown

@wagmiiii Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Chucks1093
Chucks1093 merged commit 6dfcb7f into accesslayerorg:dev Jul 25, 2026
1 check 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.

Add unit tests for the price sparkline component rendering correct number of data points

2 participants