import { ComponentFixture , TestBed } from "@angular/core/testing" ; import { AthleteSettingsFormComponent } from "./athlete-settings-form.component" ; import * as _ from "lodash" ; import { CoreModule } from "../../../core/core.module" ; import { SharedModule } from "../../../shared/shared.module" ; import { AthleteSettingsModel } from "@elevate/shared/models" ; import { userSettingsData } from "@elevate/shared/data" ; import { AthleteSettingsModule } from "../../athlete-settings.module" ; import { UserSettingsService } from "../../../shared/services/user-settings/user-settings.service" ; describe ( "AthleteSettingsFormComponent" , ( ) => { let component ; let fixture ; let userSettingsService ; beforeEach ( ( done ) => { TestBed . configureTestingModule ( { imports : [ CoreModule , SharedModule , AthleteSettingsModule ] } ) . compileComponents ( ) ; userSettingsService = TestBed . get ( UserSettingsService ) ; spyOn ( userSettingsService , "fetch" ) . and . returnValue ( Promise . resolve ( _ . cloneDeep ( userSettingsData ) ) ) ; done ( ) ; } ) ; beforeEach ( ( done ) => { fixture = TestBed . createComponent ( AthleteSettingsFormComponent ) ; component = fixture . componentInstance ; component . athleteSettingsModel = _ . cloneDeep ( AthleteSettingsModel . DEFAULT_MODEL ) ; fixture . detectChanges ( ) ; done ( ) ; } ) ; it ( "should create" , ( done ) => { expect ( component ) . toBeTruthy ( ) ; done ( ) ; } ) ; it ( "should convert runningFtp in seconds to pace using imperial system" , ( done ) => { component . athleteSettingsModel . runningFtp = 5 * 60 ; const expectedPace = "00:08:03/mi" ; const pace = component . convertToPace ( "imperial" ) ; expect ( pace ) . toEqual ( expectedPace ) ; done ( ) ; } ) ; it ( "should convert runningFtp in seconds to pace using metric system" , ( done ) => { component . athleteSettingsModel . runningFtp = 5 * 60 ; const expectedPace = "00:05:00/km" ; const pace = component . convertToPace ( "metric" ) ; expect ( pace ) . toEqual ( expectedPace ) ; done ( ) ; } ) ; } ) ;