-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'chore_release-7.3.0' into fix_RQA-2697
- Loading branch information
Showing
30 changed files
with
283 additions
and
159 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import * as React from 'react' | ||
import testFile from './__tests__/test-file.png' | ||
import { FileUpload } from '.' | ||
|
||
import type { StoryFn, Meta } from '@storybook/react' | ||
|
||
const file = new File([testFile], 'a-file-to-test.png') | ||
const handleClick = (): void => console.log('clicked the file') | ||
|
||
export default { | ||
title: 'App/Molecules/FileUpload', | ||
component: FileUpload, | ||
} as Meta | ||
|
||
const FileUploadTemplate: StoryFn< | ||
React.ComponentProps<typeof FileUpload> | ||
> = args => <FileUpload {...args} /> | ||
|
||
export const FileUploadComponent = FileUploadTemplate.bind({}) | ||
FileUploadComponent.args = { | ||
file, | ||
fileError: null, | ||
handleClick, | ||
} | ||
|
||
export const FileUploadError = FileUploadTemplate.bind({}) | ||
FileUploadError.args = { | ||
file, | ||
fileError: 'a terrible file', | ||
handleClick, | ||
} |
42 changes: 42 additions & 0 deletions
42
app/src/molecules/FileUpload/__tests__/FileUpload.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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as React from 'react' | ||
import { beforeEach, describe, expect, it, vi } from 'vitest' | ||
import { screen } from '@testing-library/react' | ||
|
||
import { renderWithProviders } from '../../../__testing-utils__' | ||
import { i18n } from '../../../i18n' | ||
import { FileUpload } from '..' | ||
import testFile from './test-file.png' | ||
|
||
const render = (props: React.ComponentProps<typeof FileUpload>) => { | ||
return renderWithProviders(<FileUpload {...props} />, { | ||
i18nInstance: i18n, | ||
})[0] | ||
} | ||
|
||
const handleClick = vi.fn() | ||
|
||
describe('FileUpload', () => { | ||
let props: React.ComponentProps<typeof FileUpload> | ||
|
||
beforeEach(() => { | ||
const file = new File([testFile], 'a-file-to-test.png') | ||
|
||
props = { | ||
file, | ||
fileError: null, | ||
handleClick, | ||
} | ||
}) | ||
it('renders file upload', () => { | ||
render(props) | ||
screen.getByText('a-file-to-test.png') | ||
const removeFile = screen.getByLabelText('remove_file') | ||
removeFile.click() | ||
expect(handleClick).toBeCalled() | ||
}) | ||
|
||
it('renders file upload error', () => { | ||
render({ ...props, fileError: 'oops this is a bad file' }) | ||
screen.getByText('oops this is a bad file') | ||
}) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
Oops, something went wrong.