import React from 'react' import { render, screen } from '@testing-library/react' import '@testing-library/jest-dom' import { Button, buttonConfig } from './index' // Mock the styles jest.mock('./styles.scss', () => ({})) describe('@joi/core/Button', () => { it('renders with default props', () => { render() const button = screen.getByRole('button', { name: /click me/i }) expect(button).toBeInTheDocument() expect(button).toHaveClass('btn btn--primary btn--medium btn--solid') }) it('applies custom className', () => { render() const badge = screen.getByText('Test Button') expect(badge).toHaveClass('custom-class') }) it('renders as a child component when asChild is true', () => { render( ) const link = screen.getByRole('link', { name: /link button/i }) expect(link).toBeInTheDocument() expect(link).toHaveClass('btn btn--primary btn--medium btn--solid') }) it.each(Object.keys(buttonConfig.variants.theme))( 'renders with theme %s', (theme) => { render() const button = screen.getByRole('button', { name: /theme button/i }) expect(button).toHaveClass(`btn btn--${theme}`) } ) it.each(Object.keys(buttonConfig.variants.variant))( 'renders with variant %s', (variant) => { render() const button = screen.getByRole('button', { name: /variant button/i }) expect(button).toHaveClass(`btn btn--${variant}`) } ) it.each(Object.keys(buttonConfig.variants.size))( 'renders with size %s', (size) => { render() const button = screen.getByRole('button', { name: /size button/i }) expect(button).toHaveClass(`btn btn--${size}`) } ) it('renders with block prop', () => { render() const button = screen.getByRole('button', { name: /block button/i }) expect(button).toHaveClass('btn btn--block') }) it('fails when a new theme is added without updating the test', () => { const expectedThemes = ['primary', 'ghost', 'icon', 'destructive'] const actualThemes = Object.keys(buttonConfig.variants.theme) expect(actualThemes).toEqual(expectedThemes) }) it('fails when a new variant is added without updating the test', () => { const expectedVariant = ['solid', 'soft', 'outline'] const actualVariants = Object.keys(buttonConfig.variants.variant) expect(actualVariants).toEqual(expectedVariant) }) it('fails when a new size is added without updating the test', () => { const expectedSizes = ['small', 'medium', 'large'] const actualSizes = Object.keys(buttonConfig.variants.size) expect(actualSizes).toEqual(expectedSizes) }) it('fails when a new variant CVA is added without updating the test', () => { const expectedVariantsCVA = ['theme', 'variant', 'size', 'block'] const actualVariant = Object.keys(buttonConfig.variants) expect(actualVariant).toEqual(expectedVariantsCVA) }) })