diff --git a/components/dashboard/RefreshButton.responsive-breakpoints.test.tsx b/components/dashboard/RefreshButton.responsive-breakpoints.test.tsx new file mode 100644 index 000000000..261153f63 --- /dev/null +++ b/components/dashboard/RefreshButton.responsive-breakpoints.test.tsx @@ -0,0 +1,76 @@ +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { render, screen, fireEvent } from '@testing-library/react'; +import RefreshButton from './RefreshButton'; + +// Mock next/navigation +const pushMock = vi.fn(); +const refreshMock = vi.fn(); + +vi.mock('next/navigation', () => ({ + useRouter: () => ({ + push: pushMock, + refresh: refreshMock, + }), + useSearchParams: () => ({ + get: vi.fn(() => null), + }), +})); + +// Mock sonner +vi.mock('sonner', () => ({ + toast: { + success: vi.fn(), + }, +})); + +describe('RefreshButton responsive breakpoints', () => { + beforeEach(() => { + vi.clearAllMocks(); + }); + + it('renders refresh button text', () => { + render(); + + expect(screen.getByText('Refresh Data')).toBeDefined(); + }); + + it('renders refresh button with accessible label', () => { + render(); + + expect(screen.getByLabelText('Refresh dashboard contribution data')).toBeDefined(); + }); + + it('renders button element correctly', () => { + render(); + + expect( + screen.getByRole('button', { + name: /refresh dashboard contribution data/i, + }) + ).toBeDefined(); + }); + + it('calls router push when clicked', () => { + render(); + + fireEvent.click( + screen.getByRole('button', { + name: /refresh dashboard contribution data/i, + }) + ); + + expect(pushMock).toHaveBeenCalled(); + }); + + it('calls router refresh when clicked', () => { + render(); + + fireEvent.click( + screen.getByRole('button', { + name: /refresh dashboard contribution data/i, + }) + ); + + expect(refreshMock).toHaveBeenCalled(); + }); +}); diff --git a/components/dashboard/tooltipUtils.type-compiler.test.ts b/components/dashboard/tooltipUtils.type-compiler.test.ts new file mode 100644 index 000000000..d46aefc2c --- /dev/null +++ b/components/dashboard/tooltipUtils.type-compiler.test.ts @@ -0,0 +1,58 @@ +import { describe, expectTypeOf, it } from 'vitest'; +import type { ActivityData } from '@/types/dashboard'; + +describe('tooltipUtils type compiler tests', () => { + it('validates ActivityData structure correctly', () => { + const validData: ActivityData = { + date: '2024-01-01', + count: 5, + intensity: 2, + }; + + expectTypeOf(validData.date).toBeString(); + expectTypeOf(validData.count).toBeNumber(); + expectTypeOf(validData.intensity).toBeNumber(); + }); + + it('ensures ActivityData array typing works', () => { + const data: ActivityData[] = [ + { + date: '2024-01-01', + count: 1, + intensity: 1, + }, + ]; + + expectTypeOf(data).toBeArray(); + }); + + it('accepts optional compatible values safely', () => { + const data: ActivityData = { + date: '2024-01-02', + count: 0, + intensity: 0, + }; + + expectTypeOf(data.count).toEqualTypeOf(); + }); + it('rejects invalid property types during compilation', () => { + expectTypeOf().toBeObject(); + + const invalidCount: ActivityData = { + date: '2024-01-01', + // @ts-expect-error count must be number + count: 'five', + intensity: 2, + }; + }); + + it('rejects missing required properties', () => { + expectTypeOf().toBeObject(); + + // @ts-expect-error intensity is required + const invalidData: ActivityData = { + date: '2024-01-01', + count: 5, + }; + }); +}); diff --git a/package-lock.json b/package-lock.json index 0259b992d..f468167e7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "dependencies": { "@resvg/resvg-js": "^2.6.2", "@tailwindcss/postcss": "^4.2.2", - "@unrs/resolver-binding-linux-x64-gnu": "*", "@vercel/analytics": "^1.6.1", "dompurify": "^3.4.7", "framer-motion": "^12.38.0",