blob: 8b2a736ae5d66b858e556cb1b6be4fc5d7bb4b35 [file] [log] [blame]
Sean Condon50855cf2018-12-23 15:37:42 +00001/*
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 { TestBed } from '@angular/core/testing';
17
18import { TrafficService } from './traffic.service';
19import {FnService, LogService} from 'gui2-fw-lib';
20import {ActivatedRoute, Params} from '@angular/router';
21import {of} from 'rxjs';
22import {TopologyService} from './topology.service';
23
24class MockActivatedRoute extends ActivatedRoute {
25 constructor(params: Params) {
26 super();
27 this.queryParams = of(params);
28 }
29}
30
31describe('TrafficService', () => {
32 let logServiceSpy: jasmine.SpyObj<LogService>;
33 let ar: ActivatedRoute;
34 let fs: FnService;
35 let mockWindow: Window;
36
37 beforeEach(() => {
38 const logSpy = jasmine.createSpyObj('LogService', ['debug', 'warn', 'info']);
39 ar = new MockActivatedRoute({'debug': 'TestService'});
40 mockWindow = <any>{
41 innerWidth: 400,
42 innerHeight: 200,
43 navigator: {
44 userAgent: 'defaultUA'
45 },
46 location: <any>{
47 hostname: 'foo',
48 host: 'foo',
49 port: '80',
50 protocol: 'http',
51 search: { debug: 'true' },
52 href: 'ws://foo:123/onos/ui/websock/path',
53 absUrl: 'ws://foo:123/onos/ui/websock/path'
54 }
55 };
56 fs = new FnService(ar, logSpy, mockWindow);
57
58 TestBed.configureTestingModule({
59 providers: [TopologyService,
60 { provide: FnService, useValue: fs},
61 { provide: LogService, useValue: logSpy },
62 { provide: ActivatedRoute, useValue: ar },
63 { provide: 'Window', useFactory: (() => mockWindow ) }
64 ]
65 });
66 logServiceSpy = TestBed.get(LogService);
67 });
68
69 it('should be created', () => {
70 const service: TrafficService = TestBed.get(TrafficService);
71 expect(service).toBeTruthy();
72 });
73});