import { ComponentFixture , TestBed , waitForAsync } from '@angular/core/testing' ; import { ImageryLoaderComponent } from './imagery-loader.component' ; import { StoreModule } from '@ngrx/store' ; import { mapFeatureKey , MapReducer } from '../../reducers/map.reducer' ; import { MockComponent } from '../../test/mock-component' ; import { TranslateModule } from '@ngx-translate/core' ; describe ( 'ImageryLoaderComponent' , ( ) => { let component ; let fixture ; const mockLoader = MockComponent ( { selector : 'ansyn-loader' , inputs : [ 'show' , 'loaderText' , 'rtl' ] } ) ; beforeEach ( waitForAsync ( ( ) => { TestBed . configureTestingModule ( { imports : [ StoreModule . forRoot ( { [ mapFeatureKey ] : MapReducer } ) , TranslateModule . forRoot ( ) ] , declarations : [ ImageryLoaderComponent , mockLoader ] } ) . compileComponents ( ) ; } ) ) ; beforeEach ( ( ) => { fixture = TestBed . createComponent ( ImageryLoaderComponent ) ; component = fixture . componentInstance ; fixture . detectChanges ( ) ; } ) ; it ( 'should create' , ( ) => { expect ( component ) . toBeTruthy ( ) ; } ) ; describe ( 'isLoading should show/hide host element' , ( ) => { it ( 'show' , ( ) => { spyOnProperty ( component , 'show' , 'get' ) . and . returnValue ( true ) ; fixture . detectChanges ( ) ; expect ( fixture . debugElement . classes . show ) . toBeTruthy ( ) ; } ) ; it ( 'hide' , ( ) => { spyOnProperty ( component , 'show' , 'get' ) . and . returnValue ( false ) ; fixture . detectChanges ( ) ; expect ( fixture . debugElement . classes . show ) . toBeFalsy ( ) ; } ) ; } ) ; } ) ;