test: add tests

This commit is contained in:
Arman
2022-11-23 12:20:52 +01:00
parent e05afbff92
commit caccb3ee2e
+22
View File
@@ -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');
});