import { ScrollTopComponent } from './../shared/scroll-top/scroll-top.component'; import { AuthenticateComponent } from './search/order-detail/authenticate/authenticate.component'; // import { Component, OnInit, OnDestroy } from '@angular/core'; // import { Router, ActivatedRoute, Route } from '@angular/router'; import { SharedService } from '../shared/shared.service'; import { UserService } from '../services/user.service'; // import { IWCToken, IChannel } from '../shared/modal/common'; // import { Logon, User } from '../shared/modal/user'; import { ErrorComponent } from '../shared/error/error.component'; // import { Observable } from 'rxjs/observable'; import { cartData, oktaConfig } from '../shared/mock-data'; // import { DebugElement } from '@angular/core'; import { FormsModule } from '@angular/forms'; import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from '@angular/core'; import { TestBed, async, fakeAsync, ComponentFixture } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; 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 { UserServiceStub } from '../services/user.service.stub'; import { TradeinService } from '../services/tradein.service'; import { LoggingService } from '../services/logging.service'; import { HomeComponent } from './home.component'; import { NavbarComponent } from '../shared/navbar/navbar.component'; import { TimeoutComponent } from '../shared/timeout/timeout.component'; import { SidebarComponent } from '../shared/sidebar/sidebar.component'; import { TitleComponent } from '../shared/title/title.component'; import { MinicartComponent } from './minicart/minicart.component'; import { CreditOptionsComponent } from './creditoptions/credit-options.component'; import { FooterComponent } from '../shared/footer/footer.component'; import { OrderNotesComponent } from '../shared/ordernotes/order-notes.component'; import { PopupComponent } from '../shared/popup/popup.component'; import { FixedPluginComponent } from '../shared/fixedplugin/fixedplugin.component'; import { ExchangeComponent } from './minicart/exchange/exchange.component'; import { RegularComponent } from './minicart/regular/regular.component'; import { AlertPluginComponent } from '../shared/alertplugin/alertplugin.component'; import { MarketingService } from '../services/marketing.service'; import { CheckoutService } from '../services/checkout.service'; import { HttpClient, HttpHandler } from '@angular/common/http'; import { SurveyComponent } from '../shared/survey/survey.component'; import { CompareService } from '../shared/compare-modal.service'; import { MoreDetailsService } from '../shared/more-details-modal.service'; import { OktaAuthService, OktaAuthModule } from '@okta/okta-angular'; // import {Conne} describe('Home Component', () => { let homeObject: HomeComponent; let fixture: ComponentFixture; let dataStub: UserServiceStub; let spyNavigate: any; // tslint:disable-next-line:prefer-const let sharedService: SharedService; beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ SharedService, UserService, CartService, CustomerService, LookupService, CatalogService, TradeinService, CheckoutService, LoggingService, MarketingService, HttpClient, HttpHandler, CompareService, MoreDetailsService, OktaAuthService ], imports: [ FormsModule, RouterTestingModule, OktaAuthModule.initAuth(oktaConfig) ], declarations: [HomeComponent, NavbarComponent, TimeoutComponent, SidebarComponent, OrderNotesComponent, TitleComponent, ErrorComponent, MinicartComponent, CreditOptionsComponent, FooterComponent, AuthenticateComponent, PopupComponent, FixedPluginComponent, ExchangeComponent, RegularComponent, AlertPluginComponent, ScrollTopComponent, SurveyComponent], schemas : [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA] }); fixture = TestBed.createComponent(HomeComponent); homeObject = fixture.componentInstance; dataStub = fixture.debugElement.injector.get(UserService); TestBed.compileComponents(); TestBed.get(SharedService); TestBed.get(CartService); TestBed.get(UserService); spyNavigate = spyOn(homeObject.router, 'navigate'); // @Suman ==> Needed to include to avoid errors if any routing is present. })); // tests here it('should be created', () => { expect(homeObject).toBeTruthy(); }); it('All methods are defined', async(() => { expect(homeObject.clearAllConfirm).toBeDefined(); expect(homeObject.showClearAllModel).toBeDefined(); expect(homeObject.showOrderNotesModal).toBeDefined(); })); it('should resolve on Title Action test data', fakeAsync(() => { spyOn(homeObject, 'showOrderNotesModal') homeObject.onTitleAction('orderNotesModal'); expect(homeObject.showOrderNotesModal).toHaveBeenCalled(); })); it('should resolve show order notes model test data', fakeAsync(() => { homeObject.cartService.cart = cartData; spyOn(homeObject.orderNotesModal, 'show') homeObject.showOrderNotesModal(); expect(homeObject.orderNotesModal.show).toHaveBeenCalled(); })); it('should resolve clear order model test data', fakeAsync(() => { homeObject.cartService.cart = cartData; spyOn(homeObject.clearAllModal, 'show') homeObject.showClearAllModel(); expect(homeObject.clearAllModal.show).toHaveBeenCalled(); })); });