blob: 72123dd7127088047ef3f259bfda1ce04d66a1c4 [file] [log] [blame]
Sean Condonfd6d11b2018-06-02 20:29:49 +01001/*
Sean Condon5ca00262018-09-06 17:55:25 +01002 * Copyright 2018-present Open Networking Foundation
Sean Condonfd6d11b2018-06-02 20:29:49 +01003 *
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';
Sean Condon5ca00262018-09-06 17:55:25 +010024import { ConsoleLoggerService } from '../../consolelogger.service';
Bhavesh72ead492018-07-19 16:29:18 +053025import { FnService } from '../../util/fn.service';
Sean Condon5ca00262018-09-06 17:55:25 +010026import { LogService } from '../../log.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010027import { GlyphService } from '../../svg/glyph.service';
Sean Condon28ecc5f2018-06-25 12:50:16 +010028import { of } from 'rxjs';
29
30class MockActivatedRoute extends ActivatedRoute {
31 constructor(params: Params) {
32 super();
33 this.queryParams = of(params);
34 }
35}
Sean Condonfd6d11b2018-06-02 20:29:49 +010036
Sean Condonfd6d11b2018-06-02 20:29:49 +010037class MockGlyphService {}
38
39describe('VeilComponent', () => {
Sean Condon28ecc5f2018-06-25 12:50:16 +010040 let fs: FnService;
41 let ar: MockActivatedRoute;
42 let windowMock: Window;
43 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condonfd6d11b2018-06-02 20:29:49 +010044
Sean Condon28ecc5f2018-06-25 12:50:16 +010045 beforeEach(async(() => {
46 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
47 ar = new MockActivatedRoute({});
48 windowMock = <any>{
49 location: <any> {
50 hostname: 'foo'
51 }
52 };
53 fs = new FnService(ar, logSpy, windowMock);
Sean Condonfd6d11b2018-06-02 20:29:49 +010054
55 TestBed.configureTestingModule({
56 declarations: [ VeilComponent ],
57 providers: [
Sean Condon28ecc5f2018-06-25 12:50:16 +010058 { provide: FnService, useValue: fs },
59 { provide: LogService, useValue: logSpy },
Sean Condonfd6d11b2018-06-02 20:29:49 +010060 { provide: GlyphService, useClass: MockGlyphService },
Sean Condon28ecc5f2018-06-25 12:50:16 +010061 { provide: 'Window', useValue: windowMock },
Sean Condonfd6d11b2018-06-02 20:29:49 +010062 ]
63 });
Sean Condon28ecc5f2018-06-25 12:50:16 +010064 logServiceSpy = TestBed.get(LogService);
65 }));
Sean Condonfd6d11b2018-06-02 20:29:49 +010066
67 it('should create', () => {
68 const fixture = TestBed.createComponent(VeilComponent);
69 const component = fixture.componentInstance;
70 expect(component).toBeTruthy();
71 });
72});