import { ScrollTopComponent } from './../shared/scroll-top/scroll-top.component'; import { EstimateComponent } from './estimate.component'; // import { Component, OnInit, OnDestroy, Pipe } from '@angular/core'; // import { Router, ActivatedRoute } from '@angular/router'; // import { DebugElement } from '@angular/core'; import {CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA} from '@angular/core'; import { FormsModule } from '@angular/forms'; import { Observable } from 'rxjs/Rx'; import { TestBed, async, fakeAsync, ComponentFixture } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; 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 { ErrorComponent } from '../shared/error/error.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 { SharedService } from '../shared/shared.service'; 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 { cartData, oktaConfig } from '../shared/mock-data'; import { CheckoutService } from '../services/checkout.service'; import { HttpClient, HttpHandler } from '@angular/common/http'; import { OktaAuthService, OktaAuthModule } from '@okta/okta-angular'; describe('Estimate Component', () => { let estimateObject: EstimateComponent; let spyNavigate: any; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ SharedService, UserService, CartService, CustomerService, LookupService, CatalogService, TradeinService, LoggingService, CheckoutService, HttpClient, HttpHandler, OktaAuthService ], imports: [ FormsModule, RouterTestingModule, OktaAuthModule.initAuth(oktaConfig) ], declarations: [EstimateComponent, NavbarComponent, TimeoutComponent, SidebarComponent, TitleComponent, ErrorComponent, FooterComponent, OrderNotesComponent, PopupComponent, FixedPluginComponent, ScrollTopComponent], schemas : [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA] }); fixture = TestBed.createComponent(EstimateComponent); TestBed.get(SharedService); TestBed.get(CartService); TestBed.get(UserService); estimateObject = fixture.componentInstance; spyNavigate = spyOn(estimateObject.router, 'navigate'); })); it('should be created', () => { expect(estimateObject).toBeTruthy(); }); it('All methods are defined', async(() => { expect(estimateObject.onTitleAction).toBeDefined(); expect(estimateObject.showOrderNotesModal).toBeDefined(); expect(estimateObject.showClearAllModel).toBeDefined(); expect(estimateObject.clearAllConfirm).toBeDefined(); })); it('should resolve on Title Action test data', fakeAsync(() => { spyOn(estimateObject, 'showOrderNotesModal') estimateObject.onTitleAction('orderNotesModal'); expect(estimateObject.showOrderNotesModal).toHaveBeenCalled(); })); it('should resolve show order notes model test data', fakeAsync(() => { estimateObject.cartService.cart = cartData; spyOn(estimateObject.orderNotesModal, 'show') estimateObject.showOrderNotesModal(); expect(estimateObject.orderNotesModal.show).toHaveBeenCalled(); })); it('should resolve clear order model test data', fakeAsync(() => { estimateObject.cartService.cart = cartData; spyOn(estimateObject.clearAllModal, 'show') estimateObject.showClearAllModel(); expect(estimateObject.clearAllModal.show).toHaveBeenCalled(); })); });