Skip to content

Commit

Permalink
feat(file-upload): hide accept labels if no accept is set
Browse files Browse the repository at this point in the history
  • Loading branch information
dpellier committed Jul 29, 2024
1 parent c1ccc23 commit 22d7626
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ export class OdsFileUpload {
{ this.dropzoneLabel }
</span>

<span class="ods-file-upload__dropzone__file-format">
{ this.acceptedFileLabel }&nbsp;{ this.accept }
</span>
{
this.accept &&
<span class="ods-file-upload__dropzone__file-format">
{ this.acceptedFileLabel }&nbsp;{ this.accept }
</span>
}

<ods-button
icon={ ODS_ICON_NAME.upload }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ describe('ods-file-upload rendering', () => {
expect((await dropzone.getComputedStyle()).getPropertyValue('background-color')).not.toBe(baseBackgroundColor);
});

it('should render the accept labels if set', async() => {
const dummyAccept = 'images/*';
const dummyAcceptLabel = 'File formats:';
await setup(`<ods-file-upload accept="${dummyAccept}" accepted-file-label="${dummyAcceptLabel}"></ods-file-upload>`);

const acceptElement = await page.find('ods-file-upload >>> .ods-file-upload__dropzone__file-format');

expect(acceptElement).not.toBeNull();
expect(acceptElement.innerText).toBe(`${dummyAcceptLabel} ${dummyAccept}`); // eslint-disable-line no-irregular-whitespace
});

it('should render the global error if set', async() => {
const dummyError = 'dummy error';
await setup(`<ods-file-upload error="${dummyError}"></ods-file-upload>`);
Expand Down

0 comments on commit 22d7626

Please sign in to comment.