From d32ed969a7c4ab1435a786f572a10a4d2d35cee0 Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Wed, 22 Mar 2017 09:57:52 +0000 Subject: [PATCH] add test and documentation staticTitle option #1570 (#1744) --- ng2-components/ng2-alfresco-upload/README.md | 2 +- .../components/upload-button.component.html | 12 +++---- .../upload-button.component.spec.ts | 35 +++++++++++++++++++ 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/ng2-components/ng2-alfresco-upload/README.md b/ng2-components/ng2-alfresco-upload/README.md index d53522d3ea..932c74d67d 100644 --- a/ng2-components/ng2-alfresco-upload/README.md +++ b/ng2-components/ng2-alfresco-upload/README.md @@ -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 diff --git a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html index f9c8343d7d..6ead8b50a4 100644 --- a/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html +++ b/ng2-components/ng2-alfresco-upload/src/components/upload-button.component.html @@ -5,8 +5,8 @@ - - + + - - + +
file_upload - - + + { 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'); + }); });