// 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 { By } from '@angular/platform-browser'; import { TestBed, async, ComponentFixture } from '@angular/core/testing'; import * as Constants from '../../../../shared/constants'; import { RouterTestingModule } from '@angular/router/testing'; import { SharedService } from '../../../../shared/shared.service'; import { UserService } from '../../../../services/user.service'; import { CheckoutService } from '../../../../services/checkout.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 { LoggingService } from '../../../../services/logging.service'; import { TradeinService } from '../../../../services/tradein.service'; import { userMockData, cartData } from '../../../../shared/mock-data'; import { AuthenticateComponent } from './authenticate.component'; import { HttpClient, HttpHandler } from '@angular/common/http'; describe('Authenticate Component', () => { let authenticateObject: AuthenticateComponent; let spyNavigate: any; let el: HTMLElement; let debugElement: DebugElement; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ SharedService, UserService, CheckoutService, CartService, CustomerService, LookupService, CatalogService, LoggingService, TradeinService, HttpClient, HttpHandler ], imports: [ FormsModule, RouterTestingModule ], declarations: [AuthenticateComponent] }); fixture = TestBed.createComponent(AuthenticateComponent); authenticateObject = fixture.componentInstance; TestBed.compileComponents(); TestBed.get(SharedService); TestBed.get(CartService); TestBed.get(UserService); authenticateObject.cartService['cart'] = cartData; authenticateObject.cart = cartData; authenticateObject['user'] = userMockData; authenticateObject.userService.user = authenticateObject['user']; const spyNavigate = spyOn(authenticateObject.router, 'navigate'); })); // tests here it('should be created', () => { expect(authenticateObject).toBeTruthy(); }); it('All methods are defined', async(() => { expect(authenticateObject.show).toBeDefined(); expect(authenticateObject.hide).toBeDefined(); expect(authenticateObject.onContainerClicked).toBeDefined(); expect(authenticateObject.confirmAuthenticate).toBeDefined(); })); it('should hide the compare modal', () => { authenticateObject.visibleAnimate = true; authenticateObject.hide(); expect(authenticateObject.visibleAnimate).toBeFalsy(); }); it('should show the compare modal', () => { authenticateObject.visibleAnimate = false; authenticateObject.show(); expect(authenticateObject.visible).toBeTruthy(); }); it('Should open the modal if it is opened and viceverse', async(() => { debugElement = fixture.debugElement.query(By.css('.fade')); el = debugElement.nativeElement; authenticateObject.show(); el.click(); expect(authenticateObject.visible).toEqual(true); })); });