// import { Component, OnInit, OnDestroy } from '@angular/core'; // import { Router, ActivatedRoute } from '@angular/router'; // import { Observable } from 'rxjs/observable'; // import { DebugElement } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { inject, tick, TestBed, getTestBed, async, fakeAsync, ComponentFixture } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { SharedService } from '../../shared/shared.service'; import { UserService } from '../../services/user.service'; import { cartData } from '../../shared/mock-data'; import { CustomerService } from '../../services/customer.service'; import { LookupService } from '../../services/lookup.service'; import { CatalogService } from '../../services/catalog.service'; import { MinicartComponent } from './minicart.component'; import { CartService } from '../../services/cart.service'; import { CartServiceStub } from '../../services/cart.service.stub'; import { IPackage } from '../../shared/modal/common'; import { ExchangeComponent } from './exchange/exchange.component'; import { RegularComponent } from './regular/regular.component'; import * as Constants from '../../shared/constants'; import { PopupComponent } from '../../shared/popup/popup.component'; import { TradeinService } from '../../services/tradein.service'; import { LoggingService } from '../../services/logging.service'; import { CheckoutService } from '../../services/checkout.service'; import { HttpClient, HttpHandler } from '@angular/common/http'; describe('Mini Cart Component', () => { let miniCartObject: MinicartComponent; let fixture: ComponentFixture; let dataStub: CartServiceStub; let spyNavigate: any; beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ SharedService, UserService, CartService, CustomerService, CheckoutService, LookupService, CatalogService, TradeinService, LoggingService, HttpClient, HttpHandler ], imports: [ FormsModule, RouterTestingModule ], declarations: [MinicartComponent, ExchangeComponent, RegularComponent, PopupComponent] }); fixture = TestBed.createComponent(MinicartComponent); miniCartObject = fixture.componentInstance; dataStub = fixture.debugElement.injector.get(CartService); TestBed.compileComponents(); TestBed.get(SharedService); TestBed.get(CartService); TestBed.get(UserService); miniCartObject['cart'] = cartData; spyNavigate = spyOn(miniCartObject.router, 'navigate'); })); // tests here it('should be created', () => { expect(miniCartObject).toBeTruthy(); }); it('All methods are defined', async(() => { expect(miniCartObject.showShoppingCart).toBeDefined(); })); it('Navigates to shopping cart', fakeAsync(() => { miniCartObject.showShoppingCart(); expect(spyNavigate).toHaveBeenCalledWith(['/home/fullcart']); })); });