feat(mobile): PinInput component — 6-digit numeric pad

This commit is contained in:
byGalax
2026-05-16 17:04:25 +02:00
parent 898b7469bb
commit 18a6365586
7 changed files with 688 additions and 4 deletions
+31
View File
@@ -0,0 +1,31 @@
import { fireEvent, render } from '@testing-library/react-native';
import { describe, expect, it, vi } from 'vitest';
import { PinInput } from './PinInput';
describe('<PinInput>', () => {
it('appends digits to the underlying value and stops at length', () => {
const onChange = vi.fn();
const { getByTestId } = render(
<PinInput value="" onChange={onChange} length={6} ariaLabel="PIN" />,
);
fireEvent.changeText(getByTestId('pin-input'), '1234567890');
expect(onChange).toHaveBeenCalledWith('123456');
});
it('strips non-digits', () => {
const onChange = vi.fn();
const { getByTestId } = render(
<PinInput value="" onChange={onChange} length={6} ariaLabel="PIN" />,
);
fireEvent.changeText(getByTestId('pin-input'), '1a2b3c');
expect(onChange).toHaveBeenCalledWith('123');
});
it('renders one bullet per filled slot', () => {
const { getAllByText } = render(
<PinInput value="123" onChange={() => {}} length={6} ariaLabel="PIN" />,
);
expect(getAllByText('•').length).toBe(3);
});
});