import { async , ComponentFixture , TestBed } from '@angular/core/testing' ; import { MatIconModule } from '@angular/material/icon' ; import { MatTableModule } from '@angular/material/table' ; import { RouterModule } from '@angular/router' ; import { RouterTestingModule } from '@angular/router/testing' ; import { MockComponent } from 'ng2-mock-component' ; import { MockPipe } from '../../mock-pipe' ; import { Tensor } from '@shared/beachball/tensor' ; import { FocalMechanismSummaryComponent } from './focal-mechanism-summary.component' ; describe ( 'FocalMechanismSummaryComponent' , ( ) => { let component ; let fixture ; beforeEach ( async ( ( ) => { TestBed . configureTestingModule ( { declarations : [ FocalMechanismSummaryComponent , MockComponent ( { inputs : [ 'fillColor' , 'labelAxes' , 'labelPlanes' , 'size' , 'tensor' ] , selector : 'shared-beachball' } ) , MockComponent ( { inputs : [ 'product' ] , selector : 'shared-product-attribution' } ) , MockComponent ( { inputs : [ 'products' ] , selector : 'technical-focal-mechanism-summary' } ) , MockComponent ( { inputs : [ 'title' ] , selector : 'shared-preferred-check' } ) , MockPipe ( 'sharedDegrees' ) , MockPipe ( 'sharedProductProperty' ) ] , imports : [ MatIconModule , MatTableModule , RouterModule , RouterTestingModule ] , providers : [ ] } ) . compileComponents ( ) ; } ) ) ; beforeEach ( ( ) => { fixture = TestBed . createComponent ( FocalMechanismSummaryComponent ) ; component = fixture . componentInstance ; fixture . detectChanges ( ) ; } ) ; it ( 'should create' , ( ) => { expect ( component ) . toBeTruthy ( ) ; } ) ; describe ( 'set products' , ( ) => { it ( 'populates tensors' , ( ) => { spyOn ( Tensor , 'fromProduct' ) . and . returnValues ( { id : 1 } , { id : 'b' } ) ; component . products = [ { } , { } ] ; expect ( component . tensors ) . toEqual ( [ { id : 1 } , { id : 'b' } ] ) ; } ) ; it ( 'clears tensors' , ( ) => { component . tensors = [ { } , { } ] ; component . products = null ; expect ( component . tensors ) . toEqual ( [ ] ) ; } ) ; } ) ; } ) ;