import { TestBed , ComponentFixture } from '@angular/core/testing' ; import { NO_ERRORS_SCHEMA } from '@angular/core' ; import { Router } from '@angular/router' ; import { AlfrescoApiService , NodeFavoriteDirective , DataTableComponent , AppConfigModule } from '@alfresco/adf-core' ; import { DocumentListComponent } from '@alfresco/adf-content-services' ; import { LibrariesComponent } from './libraries.component' ; import { AppTestingModule } from '../../testing/app-testing.module' ; import { EffectsModule } from '@ngrx/effects' ; import { LibraryEffects } from '../../store/effects' ; import { ContentApiService } from '@alfresco/aca-shared' ; describe ( 'LibrariesComponent' , ( ) => { let fixture ; let component ; let alfrescoApi ; let contentApiService ; let router ; let page ; beforeEach ( ( ) => { page = { list : { entries : [ { entry : { id : 1 } } , { entry : { id : 2 } } ] , pagination : { data : 'data' } } } ; } ) ; beforeEach ( ( ) => { TestBed . configureTestingModule ( { imports : [ AppTestingModule , EffectsModule . forRoot ( [ LibraryEffects ] ) , AppConfigModule ] , declarations : [ DataTableComponent , NodeFavoriteDirective , DocumentListComponent , LibrariesComponent ] , schemas : [ NO_ERRORS_SCHEMA ] } ) ; fixture = TestBed . createComponent ( LibrariesComponent ) ; component = fixture . componentInstance ; alfrescoApi = TestBed . inject ( AlfrescoApiService ) ; contentApiService = TestBed . inject ( ContentApiService ) ; alfrescoApi . reset ( ) ; router = TestBed . inject ( Router ) ; const sitesApi = contentApiService [ 'sitesApi' ] ; spyOn ( sitesApi , 'listSites' ) . and . returnValue ( Promise . resolve ( page ) ) ; spyOn ( sitesApi , 'listSiteMembershipsForPerson' ) . and . returnValue ( Promise . resolve ( { } ) ) ; } ) ; describe ( 'Node navigation' , ( ) => { it ( 'does not navigate when id is not passed' , ( ) => { spyOn ( router , 'navigate' ) . and . stub ( ) ; component . navigateTo ( null ) ; expect ( router . navigate ) . not . toHaveBeenCalled ( ) ; } ) ; } ) ; } ) ;