Skip to content

Commit

Permalink
Add example and visual test
Browse files Browse the repository at this point in the history
  • Loading branch information
tujoworker committed Dec 12, 2024
1 parent 822b007 commit 9fe925d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,29 @@ export const OnFileClick = () => {
</ComponentBox>
)
}

export const DisplayFileAsNonClickable = () => {
return (
<ComponentBox
hideCode
scope={{ createMockFile }}
data-visual-test="upload-value-display-file-as-non-clickable"
>
<Value.Upload
label="Label text"
value={[
{
file: createMockFile('35217511.jpg', 0, 'image/png'),
exists: false,
id: '1',
},
{
file: createMockFile('1501870.jpg', undefined, 'image/png'),
exists: false,
id: '2',
},
]}
/>
</ComponentBox>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,9 @@ import * as Examples from './Examples'
### Using `onFileClick`

<Examples.OnFileClick />

### Display files as non-clickable

When file size is 0, the file is displayed as a span instead of an anchor.

<Examples.DisplayFileAsNonClickable />
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ describe('Value.Upload', () => {
})
expect(screenshot).toMatchImageSnapshot()
})

it('have to match files as non-clickable', async () => {
const screenshot = await makeScreenshot({
selector:
'[data-visual-test="upload-value-display-file-as-non-clickable"]',
})
expect(screenshot).toMatchImageSnapshot()
})
})
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9fe925d

Please sign in to comment.