diff --git a/src/lib/components/customId.svelte b/src/lib/components/customId.svelte index 0596f9c70a..9dd9fa0c49 100644 --- a/src/lib/components/customId.svelte +++ b/src/lib/components/customId.svelte @@ -1,7 +1,7 @@ + + +
+ + + {value?.length ?? 0} + + 36 + +
+
+
+
diff --git a/tests/unit/elements/inputId.test.ts b/tests/unit/elements/inputId.test.ts new file mode 100644 index 0000000000..aa4e4c7958 --- /dev/null +++ b/tests/unit/elements/inputId.test.ts @@ -0,0 +1,22 @@ +import '@testing-library/jest-dom'; +import { render } from '@testing-library/svelte'; +import userEvent from '@testing-library/user-event'; +import { InputId } from '../../../src/lib/elements/forms'; + +test('shows id input', () => { + const { getByPlaceholderText } = render(InputId); + const input = getByPlaceholderText('Enter ID'); + + expect(input).toBeInTheDocument(); + expect(input).toHaveAttribute('type', 'text'); +}); + +test('state', async () => { + const { component, getByPlaceholderText } = render(InputId, { value: '' }); + const input = getByPlaceholderText('Enter ID'); + + console.log(component); + expect(component.value).toEqual(''); + await userEvent.type(input, 'lorem'); + expect(component.value).toEqual('lorem'); +});