| /******************************************************************************** |
| * Copyright (c) 2020 Contributors to the Eclipse Foundation |
| * |
| * See the NOTICE file(s) distributed with this work for additional |
| * information regarding copyright ownership. |
| * |
| * This program and the accompanying materials are made available under the |
| * terms of the Eclipse Public License v. 2.0 which is available at |
| * http://www.eclipse.org/legal/epl-2.0. |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| ********************************************************************************/ |
| import { GridFailureListComponent } from '@pages/grid-failure/grid-failure-list/grid-failure-list.component'; |
| import { Router } from '@angular/router'; |
| import { GridFailure } from '@shared/models'; |
| import { GridFailureSandbox } from '@pages/grid-failure/grid-failure.sandbox'; |
| import { Subscription } from 'rxjs'; |
| |
| describe('GridFailureListComponent ', () => { |
| let component: GridFailureListComponent; |
| let router: Router; |
| let sandbox: GridFailureSandbox; |
| let subscription: Subscription; |
| |
| beforeEach(() => { |
| router = { navigate() {} } as any; |
| sandbox = { endSubscriptions() {} } as any; |
| subscription = { unsubscribe() {} } as any; |
| component = new GridFailureListComponent(sandbox, router); |
| }); |
| |
| it('should create', () => { |
| expect(component).toBeTruthy(); |
| }); |
| |
| it('should initialize gridOptions context', () => { |
| component.ngOnInit(); |
| expect(component.gridOptions.context.icons.edit).toBeTruthy(); |
| }); |
| |
| it('should call appropriate functions for edit event', () => { |
| const spy: any = spyOn(router, 'navigate'); |
| component.ngOnInit(); |
| component.gridOptions.context.eventSubject.next({ type: 'edit', data: new GridFailure() }); |
| expect(spy).toHaveBeenCalled(); |
| }); |
| |
| it('should unsubscribe OnDestroy', () => { |
| const spy: any = spyOn(sandbox, 'endSubscriptions'); |
| component['_subscription'] = new Subscription(); |
| component.ngOnDestroy(); |
| expect(spy).toHaveBeenCalled(); |
| }); |
| }); |