blob: f8bbf7a00cbd24570fc97c4cacfb2ba1ec9ca77b [file] [log] [blame]
Sean Condonafe47c22019-12-19 14:28:06 +00001/*
2 * Copyright 2019-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import {async, ComponentFixture, TestBed} from '@angular/core/testing';
18
19import {PipeconfDetailsComponent} from './pipeconfdetails.component';
20import {
21 FnService, Gui2FwLibModule,
22 LogService,
23} from 'gui2-fw-lib';
24import {ActivatedRoute, Params} from '@angular/router';
25import {of} from 'rxjs';
26import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
27
28class MockActivatedRoute extends ActivatedRoute {
29 constructor(params: Params) {
30 super();
31 this.queryParams = of(params);
32 }
33}
34
35describe('PipeconfDetailsComponent', () => {
36 let fs: FnService;
37 let ar: MockActivatedRoute;
38 let windowMock: Window;
39 let logServiceSpy: jasmine.SpyObj<LogService>;
40 let component: PipeconfDetailsComponent;
41 let fixture: ComponentFixture<PipeconfDetailsComponent>;
42
43 beforeEach(async(() => {
44 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
45 ar = new MockActivatedRoute({ 'debug': 'panel' });
46 windowMock = <any>{
47 location: <any>{
48 hostname: 'foo',
49 host: 'foo',
50 port: '80',
51 protocol: 'http',
52 search: { debug: 'true' },
53 href: 'ws://foo:123/onos/ui/websock/path',
54 absUrl: 'ws://foo:123/onos/ui/websock/path'
55 }
56 };
57 fs = new FnService(ar, logSpy, windowMock);
58
59 TestBed.configureTestingModule({
60 imports: [BrowserAnimationsModule, Gui2FwLibModule],
61 declarations: [PipeconfDetailsComponent],
62 providers: [
63 { provide: FnService, useValue: fs },
64 { provide: LogService, useValue: logSpy },
65 { provide: 'Window', useValue: windowMock },
66 ]
67 }).compileComponents();
68 logServiceSpy = TestBed.get(LogService);
69
70 }));
71
72 beforeEach(() => {
73 fixture = TestBed.createComponent(PipeconfDetailsComponent);
74 component = fixture.componentInstance;
75 fixture.detectChanges();
76 });
77
78 it('should create', () => {
79 expect(component).toBeTruthy();
80 });
81});