import { describe, expect, it } from 'vitest'; import { render, screen } from '@testing-library/svelte'; import { cxTestArguments, cxTestResults } from '../../__tests__/cx-test'; import TextInput from '../text-input.svelte'; describe('Text Input', () => { it('Renders the input', () => { render(TextInput, { placeholder: 'Enter your name' }); expect(screen.getByPlaceholderText('Enter your name')).toHaveAttribute( 'type', 'text' ); }); it('Renders the input as an email input', () => { render(TextInput, { placeholder: 'Enter your email', type: 'email' }); expect(screen.getByPlaceholderText('Enter your email')).toHaveAttribute( 'type', 'email' ); }); it('Renders the input as a password input', () => { render(TextInput, { placeholder: 'Enter your password', type: 'password' }); expect(screen.getByPlaceholderText('Enter your password')).toHaveAttribute( 'type', 'password' ); }); it('Renders with the passed cx classes', () => { render(TextInput, { placeholder: 'Enter your name', cx: cxTestArguments, }); expect(screen.getByPlaceholderText('Enter your name')).toHaveClass( cxTestResults ); }); it('Renders the input as readonly', () => { render(TextInput, { placeholder: 'disabled', readonly: true, }); expect(screen.getByPlaceholderText('disabled')).toHaveClass('bg-light'); }); });