blob: 79e4153d620ab423808169724f559d13b71c32c7 [file] [log] [blame]
Sean Condonfd6d11b2018-06-02 20:29:49 +01001/*
2 * Copyright 2015-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
17/*
18 ONOS GUI -- Layer -- Veil Service - Unit Tests
19 */
20import { async, ComponentFixture, TestBed } from '@angular/core/testing';
Sean Condon28ecc5f2018-06-25 12:50:16 +010021import { ActivatedRoute, Params } from '@angular/router';
Sean Condonfd6d11b2018-06-02 20:29:49 +010022
23import { VeilComponent } from './veil.component';
24import { ConsoleLoggerService } from '../../../consolelogger.service';
Bhavesh72ead492018-07-19 16:29:18 +053025import { FnService } from '../../util/fn.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010026import { LogService } from '../../../log.service';
27import { KeyService } from '../../util/key.service';
28import { GlyphService } from '../../svg/glyph.service';
Sean Condon28ecc5f2018-06-25 12:50:16 +010029import { of } from 'rxjs';
30
31class MockActivatedRoute extends ActivatedRoute {
32 constructor(params: Params) {
33 super();
34 this.queryParams = of(params);
35 }
36}
Sean Condonfd6d11b2018-06-02 20:29:49 +010037
38class MockKeyService {}
39
40class MockGlyphService {}
41
42describe('VeilComponent', () => {
Sean Condon28ecc5f2018-06-25 12:50:16 +010043 let fs: FnService;
44 let ar: MockActivatedRoute;
45 let windowMock: Window;
46 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condonfd6d11b2018-06-02 20:29:49 +010047
Sean Condon28ecc5f2018-06-25 12:50:16 +010048 beforeEach(async(() => {
49 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
50 ar = new MockActivatedRoute({});
51 windowMock = <any>{
52 location: <any> {
53 hostname: 'foo'
54 }
55 };
56 fs = new FnService(ar, logSpy, windowMock);
Sean Condonfd6d11b2018-06-02 20:29:49 +010057
58 TestBed.configureTestingModule({
59 declarations: [ VeilComponent ],
60 providers: [
Sean Condon28ecc5f2018-06-25 12:50:16 +010061 { provide: FnService, useValue: fs },
62 { provide: LogService, useValue: logSpy },
Sean Condonfd6d11b2018-06-02 20:29:49 +010063 { provide: KeyService, useClass: MockKeyService },
64 { provide: GlyphService, useClass: MockGlyphService },
Sean Condon28ecc5f2018-06-25 12:50:16 +010065 { provide: 'Window', useValue: windowMock },
Sean Condonfd6d11b2018-06-02 20:29:49 +010066 ]
67 });
Sean Condon28ecc5f2018-06-25 12:50:16 +010068 logServiceSpy = TestBed.get(LogService);
69 }));
Sean Condonfd6d11b2018-06-02 20:29:49 +010070
71 it('should create', () => {
72 const fixture = TestBed.createComponent(VeilComponent);
73 const component = fixture.componentInstance;
74 expect(component).toBeTruthy();
75 });
76});