import { Component, OnInit, OnDestroy } from '@angular/core'; import { Router, ActivatedRoute, Route } from '@angular/router'; import { Observable } from 'rxjs/Rx'; 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.service'; import { CartService } from '../../services/cart.service'; import { UserService } from '../../services/user.service'; import { PopupComponent } from '../popup/popup.component'; 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 { notificationResponse, logoutResponse, userMockData, cartData, oktaConfig } from '../mock-data'; import * as Constants from '../../shared/constants'; import { OrderNotesComponent } from '../ordernotes/order-notes.component'; import { OrderHistoryComponent } from '../../home/customer/customer-detail/order-history/order-history.component'; import { TradeinService } from '../../services/tradein.service'; import { LoggingService } from '../../services/logging.service'; import { CheckoutService } from '../../services/checkout.service'; import { TimeoutComponent } from './timeout.component'; import {HttpClient, HttpHandler} from '@angular/common/http'; import { OktaAuthService, OktaAuthModule } from '@okta/okta-angular'; // import {Conne} describe('Timeout Component', () => { let obj: TimeoutComponent; let fixture: ComponentFixture; let sharedService: SharedService; let dataStub: UserServiceStub; let spyNavigate: any; beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ SharedService, UserService, CartService, CustomerService, LookupService, CatalogService, CheckoutService, TradeinService, LoggingService, HttpClient, HttpHandler, OktaAuthService ], imports: [ FormsModule, RouterTestingModule, OktaAuthModule.initAuth(oktaConfig) ], declarations: [TimeoutComponent, OrderNotesComponent, OrderHistoryComponent, PopupComponent] }); fixture = TestBed.createComponent(TimeoutComponent); obj = fixture.componentInstance; dataStub = fixture.debugElement.injector.get(UserService); TestBed.compileComponents(); })); // tests here it('should be created', () => { expect(obj).toBeTruthy(); }); it('All methods are defined', async(() => { expect(obj.resetIdleCounter).toBeDefined(); expect(obj.clearSession).toBeDefined(); })); it('should resolve reset counter test data', async(() => { spyOn(obj.timeoutModal, 'hide'); obj.resetIdleCounter(); expect(obj.timeoutModal.hide).toHaveBeenCalled(); })); });