import {expect, test} from 'vitest'; import {render, fireEvent} from '@testing-library/react'; import {t} from '@/scripts/i18n'; import FileInput from '@/components/FileInput'; test('click to select file', () => { const {getAllByText} = render( { /* */ }} />, ); fireEvent.click(getAllByText(t('skinlib.upload.select-file'))[1]); }); test('display file name', () => { const file = new File([], 'f.txt'); const {queryByText} = render( { /* */ }} />, ); expect(queryByText('f.txt')).toBeInTheDocument(); }); test('input file', () => { const mock = vi.fn(); const {getByLabelText} = render(); fireEvent.change(getByLabelText(t('skinlib.upload.select-file'))); expect(mock).toBeCalled(); });