blob: 6af5b82fd2b2162fa433c974ef588b49e8643ca4 [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 {PipeconfComponent} from './pipeconf.component';
20import {
21 FnService,
22 Gui2FwLibModule,
23 LogService,
24} from 'gui2-fw-lib';
25import {ActivatedRoute, Params} from '@angular/router';
26import {of} from 'rxjs';
27import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
28import {FormsModule} from '@angular/forms';
29import {RouterTestingModule} from '@angular/router/testing';
30import {PipeconfDetailsComponent} from '../pipeconfdetails/pipeconfdetails.component';
31
32class MockActivatedRoute extends ActivatedRoute {
33 constructor(params: Params) {
34 super();
35 this.queryParams = of(params);
36 }
37}
38
39/**
40 * ONOS GUI -- Pipeconf Component test - Unit Tests
41 */
42describe('PipeconfComponent', () => {
43 let fs: FnService;
44 let ar: MockActivatedRoute;
45 let windowMock: Window;
46 let logServiceSpy: jasmine.SpyObj<LogService>;
47 let component: PipeconfComponent;
48 let fixture: ComponentFixture<PipeconfComponent>;
49
50 beforeEach(async(() => {
51 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
52 ar = new MockActivatedRoute({ 'debug': 'txrx' });
53
54 windowMock = <any>{
55 location: <any>{
56 hostname: 'foo',
57 host: 'foo',
58 port: '80',
59 protocol: 'http',
60 search: { debug: 'true' },
61 href: 'ws://foo:123/onos/ui/websock/path',
62 absUrl: 'ws://foo:123/onos/ui/websock/path'
63 }
64 };
65 fs = new FnService(ar, logSpy, windowMock);
66
67 TestBed.configureTestingModule({
68 imports: [
69 BrowserAnimationsModule,
70 FormsModule,
71 RouterTestingModule,
72 Gui2FwLibModule
73 ],
74 declarations: [
75 PipeconfComponent,
76 PipeconfDetailsComponent
77 ],
78 providers: [
79 { provide: FnService, useValue: fs },
80 { provide: LogService, useValue: logSpy },
81 { provide: 'Window', useValue: windowMock },
82 ]
83 }).compileComponents();
84 logServiceSpy = TestBed.get(LogService);
85 }));
86
87 beforeEach(() => {
88 fixture = TestBed.createComponent(PipeconfComponent);
89 component = fixture.componentInstance;
90 fixture.detectChanges();
91 });
92
93 it('should create', () => {
94 expect(component).toBeTruthy();
95 });
96});