import { ComponentFixture , TestBed } from "@angular/core/testing" ; import { AppComponent } from "./app.component" ; import { TEST_SYNCED_ACTIVITIES } from "../shared-fixtures/activities-2015.fixture" ; import { ChromeEventsService } from "./shared/services/external-updates/impl/chrome-events.service" ; import { AppModule } from "./app.module" ; describe ( "AppComponent" , ( ) => { const pluginId = "c061d18abea0" ; let component = null ; let fixture = null ; beforeEach ( ( done ) => { TestBed . configureTestingModule ( { imports : [ AppModule ] } ) . compileComponents ( ) ; done ( ) ; } ) ; beforeEach ( ( done ) => { spyOn ( ChromeEventsService , "getBrowserExternalMessages" ) . and . returnValue ( { addListener : ( request , sender ) => { } } ) ; spyOn ( ChromeEventsService , "getBrowserPluginId" ) . and . returnValue ( pluginId ) ; fixture = TestBed . createComponent ( AppComponent ) ; component = fixture . componentInstance ; spyOn ( component . syncService , "getLastSyncDateTime" ) . and . returnValue ( Promise . resolve ( Date . now ( ) ) ) ; spyOn ( component . syncService . activityDao , "fetch" ) . and . returnValue ( Promise . resolve ( TEST_SYNCED_ACTIVITIES ) ) ; fixture . detectChanges ( ) ; done ( ) ; } ) ; it ( "should create the app" , ( done ) => { const app = fixture . debugElement . componentInstance ; expect ( app ) . toBeTruthy ( ) ; done ( ) ; } ) ; it ( "should update tool bar title (1)" , ( done ) => { const expected = "Global Settings" ; const route = "/globalSettings" ; const actual = AppComponent . convertRouteToTitle ( route ) ; expect ( actual ) . toBe ( expected ) ; done ( ) ; } ) ; it ( "should update tool bar title (2)" , ( done ) => { const expected = "Say Hello To World" ; const route = "/sayHelloToWorld/ohMyGod" ; const actual = AppComponent . convertRouteToTitle ( route ) ; expect ( actual ) . toBe ( expected ) ; done ( ) ; } ) ; it ( "should update tool bar title (3)" , ( done ) => { const expected = "Oh My God" ; const route = "ohMyGod" ; const actual = AppComponent . convertRouteToTitle ( route ) ; expect ( actual ) . toBe ( expected ) ; done ( ) ; } ) ; it ( "should update tool bar title (4)" , ( done ) => { const expected = "Global Settings" ; const route = "/globalSettings?viewOptionHelperId=displayAdvancedHrData" ; const actual = AppComponent . convertRouteToTitle ( route ) ; expect ( actual ) . toBe ( expected ) ; done ( ) ; } ) ; it ( "should not update tool bar title" , ( done ) => { const expected = null ; const route = null ; const actual = AppComponent . convertRouteToTitle ( route ) ; expect ( actual ) . toBeNull ( expected ) ; done ( ) ; } ) ; } ) ;