-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! Fix(web-react): FileUploaderInput className #DS-1508
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
packages/web-react/src/components/FileUploader/__tests__/FileUploaderInput.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,45 @@ | ||
import { render, screen, act } from '@testing-library/react'; | ||
import React from 'react'; | ||
import ReactDOMServer from 'react-dom/server'; | ||
import { classNamePrefixProviderTest } from '../../../../tests/providerTests/classNamePrefixProviderTest'; | ||
import { restPropsTest } from '../../../../tests/providerTests/restPropsTest'; | ||
import { validationTextPropsTest } from '../../../../tests/providerTests/validationTextPropsTest'; | ||
import FileUploaderInput from '../FileUploaderInput'; | ||
import '@testing-library/jest-dom'; | ||
|
||
describe('FileUploaderInput', () => { | ||
classNamePrefixProviderTest(FileUploaderInput, 'FileUploaderInput'); | ||
|
||
restPropsTest(FileUploaderInput, 'div'); | ||
|
||
validationTextPropsTest(FileUploaderInput, '.FileUploaderInput__validationText'); | ||
|
||
it('should have drag-and-drop listeners in CSR when draggable is supported', () => { | ||
render(<FileUploaderInput id="test-uploader" name="test-uploader" />); | ||
|
||
const dropZone = screen.getByLabelText(/upload/i).parentElement; | ||
|
||
expect(dropZone).toHaveAttribute('ondragover'); | ||
expect(dropZone).toHaveAttribute('ondragenter'); | ||
expect(dropZone).toHaveAttribute('ondragleave'); | ||
expect(dropZone).toHaveAttribute('ondrop'); | ||
}); | ||
|
||
it('should not have drag-and-drop listeners in SSR', () => { | ||
const ui = <FileUploaderInput id="test-uploader" name="test-uploader" />; | ||
const container = document.createElement('div'); | ||
document.body.appendChild(container); | ||
container.innerHTML = ReactDOMServer.renderToString(ui); | ||
|
||
act(() => { | ||
render(ui, { hydrate: true, container }); | ||
}); | ||
|
||
const dropZone = screen.getByLabelText(/upload/i).parentElement; | ||
|
||
expect(dropZone).not.toHaveAttribute('ondragover'); | ||
expect(dropZone).not.toHaveAttribute('ondragenter'); | ||
expect(dropZone).not.toHaveAttribute('ondragleave'); | ||
expect(dropZone).not.toHaveAttribute('ondrop'); | ||
}); | ||
}); |