diff --git a/packages/dnb-eufemia/src/components/upload/__tests__/UploadFileListCell.test.tsx b/packages/dnb-eufemia/src/components/upload/__tests__/UploadFileListCell.test.tsx index 260e03fd905..da836a3d61e 100644 --- a/packages/dnb-eufemia/src/components/upload/__tests__/UploadFileListCell.test.tsx +++ b/packages/dnb-eufemia/src/components/upload/__tests__/UploadFileListCell.test.tsx @@ -206,6 +206,52 @@ describe('UploadFileListCell', () => { }) }) + it('renders a span when file size is 0', () => { + const fileName = 'file.png' + + render( + + ) + expect(screen.queryByText(fileName).tagName).toBe('SPAN') + expect(screen.queryByText(fileName)).toHaveClass('dnb-span') + }) + + it('renders a span when file size is not given', () => { + const fileName = 'file.png' + + render( + + ) + expect(screen.queryByText(fileName).tagName).toBe('SPAN') + expect(screen.queryByText(fileName)).toHaveClass('dnb-span') + }) + + it('renders a button when file size is invalid, but onClick is given', () => { + const fileName = 'file.png' + + render( + + ) + + expect(screen.queryByText(fileName).parentElement.tagName).toBe( + 'BUTTON' + ) + }) + describe('File Anchor', () => { it('renders the anchor', () => { const fileName = 'file.png' @@ -216,7 +262,7 @@ describe('UploadFileListCell', () => { uploadFile={{ file: createMockFile(fileName, 100, 'image/png') }} /> ) - expect(screen.queryByText(fileName)).toBeInTheDocument() + expect(screen.queryByText(fileName).tagName).toBe('A') }) it('renders the anchor href', () => { diff --git a/packages/dnb-eufemia/src/extensions/forms/Value/Upload/__tests__/Upload.test.tsx b/packages/dnb-eufemia/src/extensions/forms/Value/Upload/__tests__/Upload.test.tsx index 6464ae6536f..b727da994fb 100644 --- a/packages/dnb-eufemia/src/extensions/forms/Value/Upload/__tests__/Upload.test.tsx +++ b/packages/dnb-eufemia/src/extensions/forms/Value/Upload/__tests__/Upload.test.tsx @@ -322,6 +322,24 @@ describe('Value.Upload', () => { }) }) + it('renders a span when file size is 0', () => { + const fileName = 'file.png' + + render( + + ) + expect(screen.queryByText(fileName).tagName).toBe('SPAN') + expect(screen.queryByText(fileName)).toHaveClass('dnb-span') + }) + describe('File Anchor', () => { it('renders the anchor', () => { const fileName = 'file.png' @@ -337,7 +355,7 @@ describe('Value.Upload', () => { ]} /> ) - expect(screen.queryByText(fileName)).toBeInTheDocument() + expect(screen.queryByText(fileName).tagName).toBe('A') }) it('executes onFileClick event when button is clicked', () => {