mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
fix eslint warnigs for core project (#7506)
This commit is contained in:
@@ -43,7 +43,7 @@ describe('CheckAllowableOperationDirective', () => {
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
changeDetectorMock = <ChangeDetectorRef> { detectChanges: () => {} };
|
||||
changeDetectorMock = { detectChanges: () => {} } as ChangeDetectorRef;
|
||||
});
|
||||
|
||||
describe('HTML nativeElement as subject', () => {
|
||||
@@ -107,7 +107,7 @@ describe('CheckAllowableOperationDirective', () => {
|
||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
|
||||
spyOn(directive, 'enableElement').and.stub();
|
||||
|
||||
directive.nodes = <any> [{}, {}];
|
||||
directive.nodes = [{}, {}] as any[];
|
||||
|
||||
expect(directive.updateElement()).toBeTruthy();
|
||||
expect(directive.enableElement).toHaveBeenCalled();
|
||||
@@ -120,7 +120,7 @@ describe('CheckAllowableOperationDirective', () => {
|
||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock);
|
||||
spyOn(directive, 'disableElement').and.stub();
|
||||
|
||||
directive.nodes = <any> [{}, {}];
|
||||
directive.nodes = [{}, {}] as any[];
|
||||
|
||||
expect(directive.updateElement()).toBeFalsy();
|
||||
expect(directive.disableElement).toHaveBeenCalled();
|
||||
@@ -137,7 +137,7 @@ describe('CheckAllowableOperationDirective', () => {
|
||||
const testComponent = new TestComponent();
|
||||
testComponent.disabled = false;
|
||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
|
||||
directive.nodes = <any> [{}, {}];
|
||||
directive.nodes = [{}, {}] as any[];
|
||||
|
||||
directive.updateElement();
|
||||
|
||||
@@ -153,7 +153,7 @@ describe('CheckAllowableOperationDirective', () => {
|
||||
const testComponent = new TestComponent();
|
||||
testComponent.disabled = true;
|
||||
const directive = new CheckAllowableOperationDirective(null, null, contentService, changeDetectorMock, testComponent);
|
||||
directive.nodes = <any> [{}, {}];
|
||||
directive.nodes = [{}, {}] as any[];
|
||||
|
||||
directive.updateElement();
|
||||
|
||||
|
@@ -116,7 +116,7 @@ describe('HighlightDirective', () => {
|
||||
const highlighter = TestBed.inject(HighlightTransformService);
|
||||
spyOn(highlighter, 'highlight').and.callThrough();
|
||||
|
||||
const callback = function() {
|
||||
const callback = () => {
|
||||
component.highlightDirectives.first.highlight('raddish', '');
|
||||
fixture.detectChanges();
|
||||
};
|
||||
|
@@ -50,7 +50,7 @@ export class LogoutDirective implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
getRedirectUri () {
|
||||
getRedirectUri() {
|
||||
if (this.redirectUri === undefined ) {
|
||||
return this.appConfig.get<string>('loginRoute', '/login');
|
||||
}
|
||||
|
@@ -137,7 +137,7 @@ describe('NodeDeleteDirective', () => {
|
||||
});
|
||||
|
||||
it('should process node successfully', (done) => {
|
||||
component.selection = <any> [{ entry: { id: '1', name: 'name1' } }];
|
||||
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||
|
||||
disposableDelete = component.deleteDirective.delete.subscribe((message) => {
|
||||
expect(message).toBe(
|
||||
@@ -272,7 +272,7 @@ describe('NodeDeleteDirective', () => {
|
||||
});
|
||||
|
||||
it('should emit event when delete is done', (done) => {
|
||||
component.selection = <any> [{ entry: { id: '1', name: 'name1' } }];
|
||||
component.selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||
fixture.detectChanges();
|
||||
|
||||
element.nativeElement.click();
|
||||
|
@@ -120,7 +120,7 @@ export class NodeDeleteDirective implements OnChanges {
|
||||
}
|
||||
|
||||
private deleteNode(node: NodeEntry | DeletedNodeEntity): Observable<ProcessedNodeData> {
|
||||
const id = (<any> node.entry).nodeId || node.entry.id;
|
||||
const id = (node.entry as any).nodeId || node.entry.id;
|
||||
|
||||
let promise: Promise<any>;
|
||||
|
||||
|
@@ -59,6 +59,7 @@ export class NodeDownloadDirective {
|
||||
/**
|
||||
* Downloads multiple selected nodes.
|
||||
* Packs result into a .ZIP archive if there is more than one node selected.
|
||||
*
|
||||
* @param selection Multiple selected nodes to download
|
||||
*/
|
||||
downloadNodes(selection: NodeEntry | Array<NodeEntry>) {
|
||||
@@ -80,6 +81,7 @@ export class NodeDownloadDirective {
|
||||
/**
|
||||
* Downloads a single node.
|
||||
* Packs result into a .ZIP archive is the node is a Folder.
|
||||
*
|
||||
* @param node Node to download
|
||||
*/
|
||||
downloadNode(node: NodeEntry) {
|
||||
@@ -95,7 +97,7 @@ export class NodeDownloadDirective {
|
||||
}
|
||||
|
||||
// Check if there's nodeId for Shared Files
|
||||
if (!entry.isFile && !entry.isFolder && (<any> entry).nodeId) {
|
||||
if (!entry.isFile && !entry.isFolder && (entry as any).nodeId) {
|
||||
this.downloadFile(node);
|
||||
}
|
||||
}
|
||||
@@ -108,7 +110,7 @@ export class NodeDownloadDirective {
|
||||
private downloadFile(node: NodeEntry) {
|
||||
if (node && node.entry) {
|
||||
// nodeId for Shared node
|
||||
const id = (<any> node.entry).nodeId || node.entry.id;
|
||||
const id = (node.entry as any).nodeId || node.entry.id;
|
||||
|
||||
let url;
|
||||
let fileName;
|
||||
|
@@ -45,7 +45,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
spyOn(directive, 'markFavoritesNodes');
|
||||
|
||||
const change = new SimpleChange(null, [], true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
|
||||
expect(directive.markFavoritesNodes).not.toHaveBeenCalledWith();
|
||||
});
|
||||
@@ -56,7 +56,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
let selection = [{ entry: { id: '1', name: 'name1' } }];
|
||||
|
||||
let change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
|
||||
expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection);
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
|
||||
expect(directive.markFavoritesNodes).toHaveBeenCalledWith(selection);
|
||||
});
|
||||
@@ -79,13 +79,13 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
let change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
tick();
|
||||
|
||||
expect(directive.hasFavorites()).toBe(true);
|
||||
|
||||
change = new SimpleChange(null, [], true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
tick();
|
||||
|
||||
expect(directive.hasFavorites()).toBe(false);
|
||||
@@ -107,7 +107,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
const change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
|
||||
tick();
|
||||
expect(favoritesApiSpy.calls.count()).toBe(2);
|
||||
@@ -121,7 +121,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
let change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
|
||||
tick();
|
||||
expect(directive.favorites.length).toBe(2);
|
||||
@@ -134,7 +134,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
|
||||
tick();
|
||||
expect(directive.favorites.length).toBe(1);
|
||||
@@ -148,7 +148,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
let change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
|
||||
tick();
|
||||
|
||||
@@ -164,7 +164,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
tick();
|
||||
|
||||
expect(directive.favorites.length).toBe(3);
|
||||
@@ -188,7 +188,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
|
||||
it('should not perform action if favorites collection is empty', fakeAsync(() => {
|
||||
const change = new SimpleChange(null, [], true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
tick();
|
||||
|
||||
directive.toggleFavorite();
|
||||
@@ -333,7 +333,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
const change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
tick();
|
||||
|
||||
expect(directive.favorites[0].entry.isFavorite).toBe(true);
|
||||
@@ -348,7 +348,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
const change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
tick();
|
||||
|
||||
expect(directive.favorites[0].entry.isFavorite).toBe(true);
|
||||
@@ -362,7 +362,7 @@ describe('NodeFavoriteDirective', () => {
|
||||
];
|
||||
|
||||
const change = new SimpleChange(null, selection, true);
|
||||
directive.ngOnChanges({'selection': change});
|
||||
directive.ngOnChanges({selection: change});
|
||||
tick();
|
||||
|
||||
expect(directive.favorites[0].entry.isFavorite).toBe(false);
|
||||
|
@@ -74,7 +74,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
if (every) {
|
||||
const batch = this.favorites.map((selected: NodeEntry | SharedLinkEntry) => {
|
||||
// shared files have nodeId
|
||||
const id = (<SharedLinkEntry> selected).entry.nodeId || selected.entry.id;
|
||||
const id = (selected as SharedLinkEntry).entry.nodeId || selected.entry.id;
|
||||
|
||||
return from(this.favoritesApi.deleteFavorite('-me-', id));
|
||||
});
|
||||
@@ -92,7 +92,7 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
const notFavorite = this.favorites.filter((node) => !node.entry.isFavorite);
|
||||
const body: FavoriteBody[] = notFavorite.map((node) => this.createFavoriteBody(node));
|
||||
|
||||
from(this.favoritesApi.createFavorite('-me-', <any> body))
|
||||
from(this.favoritesApi.createFavorite('-me-', body as any))
|
||||
.subscribe(
|
||||
() => {
|
||||
notFavorite.map((selected) => selected.entry.isFavorite = true);
|
||||
@@ -138,8 +138,8 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
}
|
||||
|
||||
// ACS 5.x and 6.x without 'isFavorite' include
|
||||
const { name, isFile, isFolder } = <Node> node;
|
||||
const id = (<SharedLink> node).nodeId || node.id;
|
||||
const { name, isFile, isFolder } = node as Node;
|
||||
const id = (node as SharedLink).nodeId || node.id;
|
||||
|
||||
const promise = this.favoritesApi.getFavorite('-me-', id);
|
||||
|
||||
@@ -153,17 +153,15 @@ export class NodeFavoriteDirective implements OnChanges {
|
||||
isFavorite: true
|
||||
}
|
||||
})),
|
||||
catchError(() => {
|
||||
return of({
|
||||
entry: {
|
||||
id,
|
||||
isFolder,
|
||||
isFile,
|
||||
name,
|
||||
isFavorite: false
|
||||
}
|
||||
});
|
||||
})
|
||||
catchError(() => of({
|
||||
entry: {
|
||||
id,
|
||||
isFolder,
|
||||
isFile,
|
||||
name,
|
||||
isFavorite: false
|
||||
}
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -69,9 +69,7 @@ describe('NodeRestoreDirective', () => {
|
||||
}));
|
||||
|
||||
translationService = TestBed.inject(TranslationService);
|
||||
spyOn(translationService, 'instant').and.callFake((key) => {
|
||||
return key;
|
||||
});
|
||||
spyOn(translationService, 'instant').and.callFake((key) => key);
|
||||
});
|
||||
|
||||
it('should not restore when selection is empty', () => {
|
||||
@@ -240,9 +238,7 @@ describe('NodeRestoreDirective', () => {
|
||||
done();
|
||||
});
|
||||
|
||||
restoreNodeSpy.and.callFake(() => {
|
||||
return Promise.resolve();
|
||||
});
|
||||
restoreNodeSpy.and.callFake(() => Promise.resolve());
|
||||
|
||||
component.selection = [
|
||||
{ entry: { id: '1', name: 'name1', path: ['somewhere-over-the-rainbow'] } },
|
||||
|
@@ -256,9 +256,9 @@ export class NodeRestoreDirective {
|
||||
path = status.success[0].entry.path;
|
||||
}
|
||||
this.restore.emit({
|
||||
message: message,
|
||||
action: action,
|
||||
path: path
|
||||
message,
|
||||
action,
|
||||
path
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import { ElementRef } from '@angular/core';
|
||||
import { FileInfo } from './../utils/file-utils';
|
||||
import { UploadDirective } from './upload.directive';
|
||||
|
||||
describe('UploadDirective', () => {
|
||||
@@ -89,21 +88,21 @@ describe('UploadDirective', () => {
|
||||
it('should prevent default event on drop', () => {
|
||||
directive.enabled = true;
|
||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||
directive.onDrop(<DragEvent> event);
|
||||
directive.onDrop(event);
|
||||
expect(event.preventDefault).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should stop default event propagation on drop', () => {
|
||||
directive.enabled = true;
|
||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||
directive.onDrop(<DragEvent> event);
|
||||
directive.onDrop(event);
|
||||
expect(event.stopPropagation).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not prevent default event on drop when disabled', () => {
|
||||
directive.enabled = false;
|
||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||
directive.onDrop(<DragEvent> event);
|
||||
directive.onDrop(event);
|
||||
expect(event.preventDefault).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -111,10 +110,7 @@ describe('UploadDirective', () => {
|
||||
directive.enabled = true;
|
||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
||||
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([
|
||||
<FileInfo> {},
|
||||
<FileInfo> {}
|
||||
]));
|
||||
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve([{}, {}]));
|
||||
spyOn(nativeElement, 'dispatchEvent').and.callFake((_) => {
|
||||
done();
|
||||
});
|
||||
@@ -123,9 +119,7 @@ describe('UploadDirective', () => {
|
||||
|
||||
it('should provide dropped files in upload-files event', (done) => {
|
||||
directive.enabled = true;
|
||||
const files = [
|
||||
<FileInfo> {}
|
||||
];
|
||||
const files = [{}];
|
||||
const event = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
|
||||
spyOn(directive, 'getDataTransfer').and.returnValue({} as any);
|
||||
spyOn(directive, 'getFilesDropped').and.returnValue(Promise.resolve(files));
|
||||
@@ -141,10 +135,8 @@ describe('UploadDirective', () => {
|
||||
it('should reset input value after file upload', () => {
|
||||
directive.enabled = true;
|
||||
directive.mode = ['click'];
|
||||
const files = [
|
||||
<FileInfo> {}
|
||||
];
|
||||
const event = {'currentTarget': {'files': files}, 'target': {'value': '/testpath/document.pdf'}};
|
||||
const files = [{}];
|
||||
const event = {currentTarget: {files}, target: {value: '/testpath/document.pdf'}};
|
||||
|
||||
directive.onSelectFiles(event);
|
||||
expect(event.target.value).toBe('');
|
||||
|
@@ -159,7 +159,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
||||
detail: {
|
||||
sender: this,
|
||||
data: this.data,
|
||||
files: files
|
||||
files
|
||||
},
|
||||
bubbles: true
|
||||
});
|
||||
@@ -192,6 +192,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
||||
|
||||
/**
|
||||
* Extract files from the DataTransfer object used to hold the data that is being dragged during a drag and drop operation.
|
||||
*
|
||||
* @param dataTransfer DataTransfer object
|
||||
*/
|
||||
getFilesDropped(dataTransfer: DataTransfer): Promise<FileInfo[]> {
|
||||
@@ -206,7 +207,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
||||
const item = items[i].webkitGetAsEntry();
|
||||
if (item) {
|
||||
if (item.isFile) {
|
||||
iterations.push(Promise.resolve(<FileInfo> {
|
||||
iterations.push(Promise.resolve({
|
||||
entry: item,
|
||||
file: items[i].getAsFile(),
|
||||
relativeFolder: '/'
|
||||
@@ -218,7 +219,7 @@ export class UploadDirective implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
iterations.push(Promise.resolve(<FileInfo> {
|
||||
iterations.push(Promise.resolve({
|
||||
entry: null,
|
||||
file: items[i].getAsFile(),
|
||||
relativeFolder: '/'
|
||||
@@ -229,11 +230,11 @@ export class UploadDirective implements OnInit, OnDestroy {
|
||||
// safari or FF
|
||||
const files = FileUtils
|
||||
.toFileArray(dataTransfer.files)
|
||||
.map((file) => <FileInfo> {
|
||||
.map((file) => ({
|
||||
entry: null,
|
||||
file: file,
|
||||
file,
|
||||
relativeFolder: '/'
|
||||
});
|
||||
}));
|
||||
|
||||
iterations.push(Promise.resolve(files));
|
||||
}
|
||||
@@ -247,17 +248,18 @@ export class UploadDirective implements OnInit, OnDestroy {
|
||||
|
||||
/**
|
||||
* Invoked when user selects files or folders by means of File Dialog
|
||||
*
|
||||
* @param event DOM event
|
||||
*/
|
||||
onSelectFiles(event: any): void {
|
||||
if (this.isClickMode()) {
|
||||
const input = (<HTMLInputElement> event.currentTarget);
|
||||
const input = event.currentTarget;
|
||||
const files = FileUtils.toFileArray(input.files);
|
||||
this.onUploadFiles(files.map((file) => <FileInfo> {
|
||||
this.onUploadFiles(files.map((file) => ({
|
||||
entry: null,
|
||||
file: file,
|
||||
file,
|
||||
relativeFolder: '/'
|
||||
}));
|
||||
})));
|
||||
event.target.value = '';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user