From e7bdbfa8491b8f365caa19338dc699b19d122a91 Mon Sep 17 00:00:00 2001 From: Manuel Friedli Date: Sat, 1 Sep 2018 01:21:06 +0200 Subject: [PATCH] Use spy objects. --- src/app/app.component.spec.ts | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index adb0d4a..36d8222 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -4,32 +4,22 @@ import {FormsModule} from '@angular/forms'; import {InputComponentManagerService} from './input-component-manager.service'; import {Step} from './step'; import {ConverterRegistryService} from './converter-registry.service'; -import {Converter} from './converter/converter'; import {VersionComponent} from './version/version.component'; +import createSpyObj = jasmine.createSpyObj; describe('AppComponent', () => { let sut: AppComponent; let fixture: ComponentFixture; const firstStep: Step = new Step(0); - const inputComponentManagerServiceStub = { - getFirst: () => { - return firstStep; - } - }; + const inputComponentManagerServiceStub = createSpyObj(['getFirst']); + inputComponentManagerServiceStub.getFirst.and.returnValue(firstStep); - const converterRegistryServiceStub = { - getAllConverters: (): Converter[] => { - return []; - }, - - getConverter: (id: string): Converter => { - return undefined; - } - }; + const converterRegistryServiceStub = createSpyObj(['getAllConverters', 'getConverter']); + converterRegistryServiceStub.getAllConverters.and.returnValue([]); + converterRegistryServiceStub.getConverter.and.returnValue(undefined); beforeEach(async(() => { - /*return */ TestBed.configureTestingModule({ declarations: [AppComponent, VersionComponent], imports: [FormsModule],