blob: c246428757d7ac7e4880ecbd940fdef00a5c7d75 [file] [log] [blame]
Sean Condonf4f54a12018-10-10 23:25:46 +01001/*
2 * Copyright 2018-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 */
16import { async, ComponentFixture, TestBed } from '@angular/core/testing';
17import { ActivatedRoute, Params } from '@angular/router';
18import { of } from 'rxjs';
19import { SummaryComponent } from './summary.component';
20import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
21
22import {
23 FnService,
24 LogService
Sean Condon3b3fdab2020-04-14 09:25:00 +010025} from 'org_onosproject_onos/web/gui2-fw-lib/public_api';
Sean Condonf4f54a12018-10-10 23:25:46 +010026
27class MockActivatedRoute extends ActivatedRoute {
28 constructor(params: Params) {
29 super();
30 this.queryParams = of(params);
31 }
32}
33
34/**
35 * ONOS GUI -- Topology View Summary Panel -- Unit Tests
36 */
37describe('SummaryComponent', () => {
38 let fs: FnService;
39 let ar: MockActivatedRoute;
40 let windowMock: Window;
41 let logServiceSpy: jasmine.SpyObj<LogService>;
42 let component: SummaryComponent;
43 let fixture: ComponentFixture<SummaryComponent>;
44
45 beforeEach(async(() => {
46 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
47 ar = new MockActivatedRoute({ 'debug': 'txrx' });
48
49 windowMock = <any>{
50 location: <any>{
51 hostname: 'foo',
52 host: 'foo',
53 port: '80',
54 protocol: 'http',
55 search: { debug: 'true' },
56 href: 'ws://foo:123/onos/ui/websock/path',
57 absUrl: 'ws://foo:123/onos/ui/websock/path'
58 }
59 };
60 fs = new FnService(ar, logSpy, windowMock);
61
62 TestBed.configureTestingModule({
63 imports: [ BrowserAnimationsModule ],
64 declarations: [ SummaryComponent ],
65 providers: [
66 { provide: FnService, useValue: fs },
67 { provide: LogService, useValue: logSpy },
68 { provide: 'Window', useValue: windowMock },
69 ]
70 })
71 .compileComponents();
72 logServiceSpy = TestBed.get(LogService);
73 }));
74
75 beforeEach(() => {
76 fixture = TestBed.createComponent(SummaryComponent);
77 component = fixture.componentInstance;
78 fixture.detectChanges();
79 });
80
81 it('should create', () => {
82 expect(component).toBeTruthy();
83 });
84});