// import { Component, OnInit, OnDestroy } from '@angular/core'; // import { Router, ActivatedRoute } from '@angular/router'; // import { DebugElement } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { Observable } from 'rxjs/Rx'; import { SharedService } from '../../shared/shared.service'; import { RouterTestingModule } from '@angular/router/testing'; import { CreditOptionsComponent } from './credit-options.component'; import { UserService } from '../../services/user.service'; import { CartService } from '../../services/cart.service'; import { CustomerService } from '../../services/customer.service'; import { LookupService } from '../../services/lookup.service'; import { CatalogService } from '../../services/catalog.service'; import { TradeinService } from '../../services/tradein.service'; import { LoggingService } from '../../services/logging.service'; import { CheckoutService } from '../../services/checkout.service'; import { TestBed, async, ComponentFixture } from '@angular/core/testing'; import { HttpClient, HttpHandler } from '@angular/common/http'; describe('Credit options component', () => { let obj: CreditOptionsComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ SharedService, UserService, CartService, CustomerService, CheckoutService, LookupService, CatalogService, TradeinService, LoggingService, HttpClient, HttpHandler ], imports: [ FormsModule, RouterTestingModule ], declarations: [CreditOptionsComponent] }); fixture = TestBed.createComponent(CreditOptionsComponent); obj = fixture.componentInstance; TestBed.compileComponents(); TestBed.get(SharedService); TestBed.get(CartService); TestBed.get(UserService); })); // tests here it('should be created', () => { expect(obj).toBeTruthy(); }); it('All methods are defined', async(() => { expect(obj.updateCreditOption).toBeDefined(); })); it('credit option is updated accordingly', () => { const creditOption = { 'creditType': 'NC' } spyOn(obj.sharedService, 'updateCreditChoice'); obj.updateCreditOption(creditOption); expect(obj.sharedService.updateCreditChoice).toHaveBeenCalledWith('NC'); }); });