From bce6d36cfc48a78aeef8606a5e0edd670bda4a23 Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 17 May 2025 10:24:25 -0500 Subject: [PATCH] refactor: convert CircleBackground test to TypeScript --- ...ckground.test.jsx => CircleBackground.test.tsx} | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) rename src/__tests__/components/{CircleBackground.test.jsx => CircleBackground.test.tsx} (79%) diff --git a/src/__tests__/components/CircleBackground.test.jsx b/src/__tests__/components/CircleBackground.test.tsx similarity index 79% rename from src/__tests__/components/CircleBackground.test.jsx rename to src/__tests__/components/CircleBackground.test.tsx index 97c5d6e0..a59bdb3b 100644 --- a/src/__tests__/components/CircleBackground.test.jsx +++ b/src/__tests__/components/CircleBackground.test.tsx @@ -15,7 +15,7 @@ describe('CircleBackground', () => { it('renders an SVG element with correct attributes', () => { render() - const svg = screen.getByTestId('circle-bg') + const svg = screen.getByTestId('circle-bg') as SVGSVGElement expect(svg).toBeInTheDocument() expect(svg.tagName).toBe('svg') expect(svg).toHaveAttribute('viewBox', '0 0 558 558') @@ -27,18 +27,22 @@ describe('CircleBackground', () => { it('uses the provided color for gradient and stroke', () => { render() - const svg = screen.getByTestId('circle-bg') + const svg = screen.getByTestId('circle-bg') as SVGSVGElement const stopElement = svg.querySelector('stop') - expect(stopElement).toHaveAttribute('stop-color', '#123456') + expect(stopElement).not.toBeNull() + if (stopElement) { + expect(stopElement).toHaveAttribute('stop-color', '#123456') + } const pathElements = svg.querySelectorAll('path') + expect(pathElements.length).toBeGreaterThan(0) expect(pathElements[0]).toHaveAttribute('stroke', '#123456') }) it('applies custom width and height', () => { render() - const svg = screen.getByTestId('circle-bg') + const svg = screen.getByTestId('circle-bg') as SVGSVGElement expect(svg).toHaveAttribute('width', '300') expect(svg).toHaveAttribute('height', '400') }) @@ -53,7 +57,7 @@ describe('CircleBackground', () => { />, ) - const svg = screen.getByTestId('circle-bg') + const svg = screen.getByTestId('circle-bg') as SVGSVGElement expect(svg).toHaveAttribute('class', 'custom-class') expect(svg).toHaveAttribute('id', 'custom-id') })