mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
Single naming convention for core services (#1363)
* remove temporary file from repo * fix: alfresco-api.service * new: auth.service.ts - new auth.service.ts implementation - deprecation warning for AlfrescoAuthenticationService - fix ‘clean-build’ typo - extra vscode settings for ‘.d.ts’ files * use AuthService internally * new: content.service.ts - deprecation warning for AlfrescoContentService - use new ContentService internally * new: settings.service.ts - new SettingsService - deprecation warning for AlfrescoSettingsService - using new SettingsService internally * new: translate.service and translate-loader.service - custom TranslateLoader becomes AlfrescoTranslateLoader - custom TranslateService becomes AlfrescoTranslateService - deprecation notices for old service and loader implementations * fix: document list * fix: search * fix: tag also fixes #1364 * fix: activiti form * fix: activiti tasklist, improve unit tests * fix: activiti processlist, unit tests improvements * fix: diagram component * fix: analytics component * fix: upload component - fix numerous issues with unit tests (hidden by ‘any’ type) - test improvements * fix: webscript * fix: userinfo unit tests * code fixes * fix 'beforeAll' issue * tasklist unit testing improvements * fix: form unit tests * fix: unit tests
This commit is contained in:
committed by
Maurizio Vitale
parent
92fc7d1df3
commit
facafbd55c
@@ -18,17 +18,11 @@
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { UploadButtonComponent } from './upload-button.component';
|
||||
import { DebugElement } from '@angular/core';
|
||||
import {
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoApiService,
|
||||
CoreModule,
|
||||
AlfrescoTranslationService
|
||||
} from 'ng2-alfresco-core';
|
||||
import { CoreModule, AlfrescoTranslateService } from 'ng2-alfresco-core';
|
||||
import { TranslationMock } from '../assets/translation.service.mock';
|
||||
import { UploadService } from '../services/upload.service';
|
||||
|
||||
describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
describe('UploadButtonComponent', () => {
|
||||
|
||||
let file = {name: 'fake-name-1', size: 10, webkitRelativePath: 'fake-folder1/fake-name-1.json'};
|
||||
let fakeEvent = {
|
||||
@@ -63,23 +57,23 @@ describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
reject(fakeRejectRest);
|
||||
});
|
||||
|
||||
let component: any;
|
||||
let component: UploadButtonComponent;
|
||||
let fixture: ComponentFixture<UploadButtonComponent>;
|
||||
let debug: DebugElement;
|
||||
let element: HTMLElement;
|
||||
let uploadService: UploadService;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
CoreModule
|
||||
CoreModule.forRoot()
|
||||
],
|
||||
declarations: [
|
||||
UploadButtonComponent
|
||||
],
|
||||
declarations: [UploadButtonComponent],
|
||||
providers: [
|
||||
AlfrescoSettingsService,
|
||||
AlfrescoAuthenticationService,
|
||||
AlfrescoApiService,
|
||||
UploadService,
|
||||
{ provide: AlfrescoTranslationService, useClass: TranslationMock }
|
||||
{ provide: AlfrescoTranslateService, useClass: TranslationMock }
|
||||
]
|
||||
}).compileComponents();
|
||||
}));
|
||||
@@ -88,6 +82,7 @@ describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
window['componentHandler'] = null;
|
||||
|
||||
fixture = TestBed.createComponent(UploadButtonComponent);
|
||||
uploadService = TestBed.get(UploadService);
|
||||
|
||||
debug = fixture.debugElement;
|
||||
element = fixture.nativeElement;
|
||||
@@ -115,7 +110,7 @@ describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
});
|
||||
|
||||
it('should render an uploadFolder button if uploadFolder is true', () => {
|
||||
component.uploadFolder = true;
|
||||
component.uploadFolders = true;
|
||||
let compiled = fixture.debugElement.nativeElement;
|
||||
fixture.detectChanges();
|
||||
expect(compiled.querySelector('#uploadFolder')).toBeDefined();
|
||||
@@ -124,31 +119,31 @@ describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
it('should call uploadFile with the default root folder', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
|
||||
component.onSuccess = null;
|
||||
component._uploaderService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
uploadService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onFilesAdded(fakeEvent);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('-root-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
expect(uploadService.uploadFilesInTheQueue).toHaveBeenCalledWith('-root-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
});
|
||||
|
||||
it('should call uploadFile with a custom root folder', () => {
|
||||
component.currentFolderPath = '/root-fake-/sites-fake/folder-fake';
|
||||
component.rootFolderId = '-my-';
|
||||
component.onSuccess = null;
|
||||
component._uploaderService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
uploadService.uploadFilesInTheQueue = jasmine.createSpy('uploadFilesInTheQueue');
|
||||
|
||||
fixture.detectChanges();
|
||||
|
||||
component.onFilesAdded(fakeEvent);
|
||||
expect(component._uploaderService.uploadFilesInTheQueue).toHaveBeenCalledWith('-my-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
expect(uploadService.uploadFilesInTheQueue).toHaveBeenCalledWith('-my-', '/root-fake-/sites-fake/folder-fake', null);
|
||||
});
|
||||
|
||||
it('should create a folder and emit an File uploaded event', (done) => {
|
||||
component.currentFolderPath = '/fake-root-path';
|
||||
fixture.detectChanges();
|
||||
|
||||
spyOn(component._uploaderService, 'callApiCreateFolder').and.returnValue(fakeResolvePromise);
|
||||
spyOn(uploadService, 'callApiCreateFolder').and.returnValue(fakeResolvePromise);
|
||||
|
||||
component.onSuccess.subscribe(e => {
|
||||
expect(e.value).toEqual('File uploaded');
|
||||
@@ -165,7 +160,7 @@ describe('Test ng2-alfresco-upload UploadButton', () => {
|
||||
});
|
||||
|
||||
it('should emit an onError event when the folder already exist', (done) => {
|
||||
spyOn(component._uploaderService, 'callApiCreateFolder').and.returnValue(fakeRejectPromise);
|
||||
spyOn(uploadService, 'callApiCreateFolder').and.returnValue(fakeRejectPromise);
|
||||
component.onError.subscribe(e => {
|
||||
expect(e.value).toEqual('FILE_UPLOAD.MESSAGES.FOLDER_ALREADY_EXIST');
|
||||
done();
|
||||
|
Reference in New Issue
Block a user