add test and documentation staticTitle option #1570 (#1744)

This commit is contained in:
Eugenio Romano
2017-03-22 09:57:52 +00:00
committed by Denys Vuika
parent 62915aff93
commit d32ed969a7
3 changed files with 42 additions and 7 deletions

View File

@@ -177,7 +177,7 @@ Attribute | Options | Default | Description | Mandatory
`acceptedFilesType` | *string* | * | array of allowed file extensions , example: ".jpg,.gif,.png,.svg" |
`currentFolderPath` | *string* | '/Sites/swsdp/documentLibrary' | define the path where the files are uploaded |
`versioning` | *boolean* | false | Versioning false is the default uploader behaviour and it rename using an integer suffix if there is a name clash. Versioning true to indicate that a major version should be created |
`staticTitle` | *string* | 'FILE_UPLOAD.BUTTON.UPLOAD_FILE' or 'FILE_UPLOAD.BUTTON.UPLOAD_FOLDER' string in the JSON text file | define the text of the upload button|
### Drag and drop

View File

@@ -5,8 +5,8 @@
<!--Multiple Files Upload-->
<span *ngIf="multipleFiles">
<label *ngIf="!staticTitle" for="upload-multiple-files">{{'FILE_UPLOAD.BUTTON.UPLOAD_FILE' | translate}}</label>
<label *ngIf="staticTitle" for="upload-multiple-files">{{staticTitle}}</label>
<label id="upload-multiple-file-label" *ngIf="!staticTitle" for="upload-multiple-files">{{'FILE_UPLOAD.BUTTON.UPLOAD_FILE' | translate}}</label>
<label id="upload-multiple-file-label-static" *ngIf="staticTitle" for="upload-multiple-files">{{staticTitle}}</label>
<input id="upload-multiple-files" data-automation-id="upload-multiple-files" type="file" name="uploadFiles"
(change)="onFilesAdded($event)"
multiple="multiple"
@@ -16,8 +16,8 @@
<!--Single Files Upload-->
<span *ngIf="!multipleFiles">
<label *ngIf="!staticTitle" for="upload-single-file">{{'FILE_UPLOAD.BUTTON.UPLOAD_FILE' | translate}}</label>
<label *ngIf="staticTitle" for="upload-single-file">{{staticTitle}}</label>
<label id="upload-single-file-label" *ngIf="!staticTitle" for="upload-single-file">{{'FILE_UPLOAD.BUTTON.UPLOAD_FILE' | translate}}</label>
<label id="upload-single-file-label-static" *ngIf="staticTitle" for="upload-single-file">{{staticTitle}}</label>
<input id="upload-single-file" data-automation-id="upload-single-file" type="file" name="uploadFiles"
(change)="onFilesAdded($event)"
accept="{{acceptedFilesType}}"
@@ -28,8 +28,8 @@
<!--Folders Upload-->
<div *ngIf="uploadFolders" class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored mdl-button--file">
<i class="material-icons">file_upload</i>
<label *ngIf="!staticTitle" for="uploadFolder">{{'FILE_UPLOAD.BUTTON.UPLOAD_FOLDER' | translate}}</label>
<label *ngIf="staticTitle" for="uploadFolder">{{staticTitle}}</label>
<label id="uploadFolder-label" *ngIf="!staticTitle" for="uploadFolder">{{'FILE_UPLOAD.BUTTON.UPLOAD_FOLDER' | translate}}</label>
<label id="uploadFolder-label-static" *ngIf="staticTitle" for="uploadFolder">{{staticTitle}}</label>
<input id="uploadFolder" data-automation-id="uploadFolder" type="file" name="uploadFiles"
(change)="onDirectoryAdded($event)"
multiple="multiple"

View File

@@ -169,4 +169,39 @@ describe('UploadButtonComponent', () => {
component.onDirectoryAdded(fakeEvent);
});
it('should by default the title of the button get from the JSON file', () => {
let compiled = fixture.debugElement.nativeElement;
fixture.detectChanges();
component.uploadFolders = false;
component.multipleFiles = false;
expect(compiled.querySelector('#upload-single-file-label').textContent).toEqual('FILE_UPLOAD.BUTTON.UPLOAD_FILE');
component.multipleFiles = true;
fixture.detectChanges();
expect(compiled.querySelector('#upload-multiple-file-label').textContent).toEqual('FILE_UPLOAD.BUTTON.UPLOAD_FILE');
component.uploadFolders = true;
fixture.detectChanges();
expect(compiled.querySelector('#uploadFolder-label').textContent).toEqual('FILE_UPLOAD.BUTTON.UPLOAD_FOLDER');
});
it('should staticTitle properties change the title of the upload buttons', () => {
let compiled = fixture.debugElement.nativeElement;
component.staticTitle = 'test-text';
component.uploadFolders = false;
component.multipleFiles = false;
fixture.detectChanges();
expect(compiled.querySelector('#upload-single-file-label-static').textContent).toEqual('test-text');
component.multipleFiles = true;
fixture.detectChanges();
expect(compiled.querySelector('#upload-multiple-file-label-static').textContent).toEqual('test-text');
component.uploadFolders = true;
fixture.detectChanges();
expect(compiled.querySelector('#uploadFolder-label-static').textContent).toEqual('test-text');
});
});