- Switched to pnpm - Updated to typescript 4.9.5 - JSX transforms switched to react-jsx - Use swc for typescript transforms - Remove deprecated dependencies - Cleanup unused types - Some ESM fixes - PostCSS config now lives in package.json - Bump support target TODO: - switch to vite or plain esbuild - jest to vitest / uvu - jquery to cash-dom - pure ESM (lodash-es, etc.) - drop prettier & husky (lint-staged is okay) - drop wasm cli & xterm.js - update bootstrap
39 lines
864 B
TypeScript
39 lines
864 B
TypeScript
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(
|
|
<FileInput
|
|
file={null}
|
|
onChange={() => {
|
|
/* */
|
|
}}
|
|
/>,
|
|
)
|
|
|
|
fireEvent.click(getAllByText(t('skinlib.upload.select-file'))[1]!)
|
|
})
|
|
|
|
test('display file name', () => {
|
|
const file = new File([], 'f.txt')
|
|
const { queryByText } = render(
|
|
<FileInput
|
|
file={file}
|
|
onChange={() => {
|
|
/* */
|
|
}}
|
|
/>,
|
|
)
|
|
expect(queryByText('f.txt')).toBeInTheDocument()
|
|
})
|
|
|
|
test('input file', () => {
|
|
const mock = jest.fn()
|
|
|
|
const { getByLabelText } = render(<FileInput file={null} onChange={mock} />)
|
|
fireEvent.change(getByLabelText(t('skinlib.upload.select-file')))
|
|
|
|
expect(mock).toBeCalled()
|
|
})
|