// 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 { TestBed, async, fakeAsync, 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 { cartData } from '../../../../shared/spec.constants'; import { userMockData, packagesData } from '../../../../shared/mock-data'; import { OrderInfoComponent } from './order-info.component'; import { ORDER_STATUS } from '../../../../shared/form.constants'; import { HttpClient, HttpHandler } from '@angular/common/http'; import { RouterTestingModule } from '@angular/router/testing'; describe('Order Info Component', () => { let orderInfoObject: OrderInfoComponent; let fixture: ComponentFixture; beforeEach(async(() => { TestBed.configureTestingModule({ providers: [ SharedService, UserService, CheckoutService, CartService, CustomerService, LookupService, CatalogService, LoggingService, TradeinService, HttpClient, HttpHandler ], imports: [ FormsModule, RouterTestingModule ], declarations: [OrderInfoComponent] }); fixture = TestBed.createComponent(OrderInfoComponent); orderInfoObject = fixture.componentInstance; TestBed.compileComponents(); TestBed.get(SharedService); TestBed.get(CartService); TestBed.get(UserService); orderInfoObject['cart'] = cartData; orderInfoObject['user'] = userMockData; orderInfoObject.financeType = orderInfoObject.getFinanceType(); })); // tests here it('should be created', () => { expect(orderInfoObject).toBeTruthy(); }); it('All methods are defined', async(() => { expect(orderInfoObject.getChannelLabel).toBeDefined(); expect(orderInfoObject.getStatusLabel).toBeDefined(); })); it('Channel Status is mapped correctly', fakeAsync(() => { let channelStatus: string; orderInfoObject['orderStoresItems'] = [Constants.STORE_ID_BD, Constants.STORE_ID_MYTMO]; channelStatus = orderInfoObject.getChannelLabel(Constants.STORE_ID_CD); expect(channelStatus).toEqual('Not Found'); })); it('Order Status is mapped correctly', fakeAsync(() => { let orderStatus: string; orderInfoObject.orderStatusItems = ORDER_STATUS.filter(orderStatusItem => orderStatusItem); orderStatus = orderInfoObject.getStatusLabel('ppp'); expect(orderStatus).toEqual('Not Found'); })); it('should return matching package', async(() => { orderInfoObject.cart.packages = packagesData; orderInfoObject.getRefType('voice'); expect(orderInfoObject.cart.packages[0].packageType).toEqual('accessory'); })); it('Channel Status is mapped correctly', fakeAsync(() => { let channelStatus: string; orderInfoObject['orderStoresItems'] = [Constants.STORE_ID_BD, Constants.STORE_ID_MYTMO]; channelStatus = orderInfoObject.getChannelLabel(Constants.STORE_ID_CD); expect(channelStatus).toEqual('Not Found'); })); });