mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
Prettier upgrade and e2e type checks (#1522)
* upgrade prettier * noImplicitAny rule * fix type * update tsconfig * upgrade to 150 print width
This commit is contained in:
@@ -52,9 +52,7 @@ describe('ExtensionsDataLoaderGuard', () => {
|
||||
|
||||
it('should emit true and complete in case of only one callback is present, completed', () => {
|
||||
const subject = new Subject<true>();
|
||||
const guard = new ExtensionsDataLoaderGuard([
|
||||
() => subject.asObservable()
|
||||
]);
|
||||
const guard = new ExtensionsDataLoaderGuard([() => subject.asObservable()]);
|
||||
|
||||
guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy);
|
||||
|
||||
@@ -70,9 +68,7 @@ describe('ExtensionsDataLoaderGuard', () => {
|
||||
});
|
||||
|
||||
it('should emit true and complete in case of only one callback is present, errored', () => {
|
||||
const guard = new ExtensionsDataLoaderGuard([
|
||||
() => throwError(new Error())
|
||||
]);
|
||||
const guard = new ExtensionsDataLoaderGuard([() => throwError(new Error())]);
|
||||
|
||||
guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy);
|
||||
expect(emittedSpy).toHaveBeenCalledWith(true);
|
||||
@@ -83,10 +79,7 @@ describe('ExtensionsDataLoaderGuard', () => {
|
||||
it('should NOT complete in case of multiple callbacks are present and not all of them have been completed', () => {
|
||||
const subject1 = new Subject<true>();
|
||||
const subject2 = new Subject<true>();
|
||||
const guard = new ExtensionsDataLoaderGuard([
|
||||
() => subject1.asObservable(),
|
||||
() => subject2.asObservable()
|
||||
]);
|
||||
const guard = new ExtensionsDataLoaderGuard([() => subject1.asObservable(), () => subject2.asObservable()]);
|
||||
|
||||
guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy);
|
||||
|
||||
@@ -101,10 +94,7 @@ describe('ExtensionsDataLoaderGuard', () => {
|
||||
it('should emit true and complete in case of multiple callbacks are present and all of them have been completed', () => {
|
||||
const subject1 = new Subject<true>();
|
||||
const subject2 = new Subject<true>();
|
||||
const guard = new ExtensionsDataLoaderGuard([
|
||||
() => subject1.asObservable(),
|
||||
() => subject2.asObservable()
|
||||
]);
|
||||
const guard = new ExtensionsDataLoaderGuard([() => subject1.asObservable(), () => subject2.asObservable()]);
|
||||
|
||||
guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy);
|
||||
|
||||
@@ -119,10 +109,7 @@ describe('ExtensionsDataLoaderGuard', () => {
|
||||
|
||||
it('should emit true and complete even if one of the observables are errored, to not block the application loading', () => {
|
||||
const subject1 = new Subject<true>();
|
||||
const guard = new ExtensionsDataLoaderGuard([
|
||||
() => subject1.asObservable(),
|
||||
() => throwError(new Error())
|
||||
]);
|
||||
const guard = new ExtensionsDataLoaderGuard([() => subject1.asObservable(), () => throwError(new Error())]);
|
||||
|
||||
guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy);
|
||||
|
||||
@@ -135,7 +122,7 @@ describe('ExtensionsDataLoaderGuard', () => {
|
||||
it('should call canActivate only once', () => {
|
||||
const subject1 = new Subject<true>();
|
||||
const extensionLoaders = {
|
||||
fct1: function() {
|
||||
fct1: function () {
|
||||
return subject1.asObservable();
|
||||
}
|
||||
};
|
||||
|
@@ -28,17 +28,13 @@ import { CanActivate, ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { Observable, forkJoin, of } from 'rxjs';
|
||||
import { map, catchError } from 'rxjs/operators';
|
||||
|
||||
export type ExtensionLoaderCallback = (
|
||||
route: ActivatedRouteSnapshot
|
||||
) => Observable<boolean>;
|
||||
export type ExtensionLoaderCallback = (route: ActivatedRouteSnapshot) => Observable<boolean>;
|
||||
|
||||
export function DefaultExtensionLoaderFactory() {
|
||||
return [];
|
||||
}
|
||||
|
||||
export const EXTENSION_DATA_LOADERS = new InjectionToken<
|
||||
ExtensionLoaderCallback[]
|
||||
>('EXTENSION_DATA_LOADERS', {
|
||||
export const EXTENSION_DATA_LOADERS = new InjectionToken<ExtensionLoaderCallback[]>('EXTENSION_DATA_LOADERS', {
|
||||
providedIn: 'root',
|
||||
factory: DefaultExtensionLoaderFactory
|
||||
});
|
||||
@@ -60,20 +56,16 @@ export class ExtensionsDataLoaderGuard implements CanActivate {
|
||||
return of(true);
|
||||
}
|
||||
|
||||
const dataLoaderCallbacks = this.extensionDataLoaders.map(callback =>
|
||||
callback(route)
|
||||
);
|
||||
const dataLoaderCallbacks = this.extensionDataLoaders.map((callback) => callback(route));
|
||||
|
||||
// Undocumented forkJoin behaviour/bug:
|
||||
// https://github.com/ReactiveX/rxjs/issues/3246
|
||||
// So all callbacks need to emit before completion, otherwise forkJoin will short circuit
|
||||
return forkJoin(...dataLoaderCallbacks).pipe(
|
||||
map(() => true),
|
||||
catchError(e => {
|
||||
catchError((e) => {
|
||||
// tslint:disable-next-line
|
||||
console.error(
|
||||
'Some of the extension data loader guards has been errored.'
|
||||
);
|
||||
console.error('Some of the extension data loader guards has been errored.');
|
||||
// tslint:disable-next-line
|
||||
console.error(e);
|
||||
return of(true);
|
||||
|
Reference in New Issue
Block a user