blob: 7a1550456a3149f86e4d39a462ca48159b677158 [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +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 { TestBed, async } from '@angular/core/testing';
Sean Condonfd6d11b2018-06-02 20:29:49 +010017import { RouterModule, RouterOutlet, ChildrenOutletContexts, ActivatedRoute, Params } from '@angular/router';
18import { of } from 'rxjs';
19
Sean Condon49e15be2018-05-16 16:58:29 +010020import { LogService } from '../../app/log.service';
21import { ConsoleLoggerService } from '../../app/consolelogger.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010022
Sean Condon49e15be2018-05-16 16:58:29 +010023import { IconComponent } from '../../app/fw/svg/icon/icon.component';
24import { MastComponent } from '../../app/fw/mast/mast/mast.component';
25import { NavComponent } from '../../app/fw/nav/nav/nav.component';
Sean Condon83fc39f2018-04-19 18:56:13 +010026import { OnosComponent } from '../../app/onos.component';
Sean Condonfd6d11b2018-06-02 20:29:49 +010027import { VeilComponent } from '../../app/fw/layer/veil/veil.component';
28
Sean Condon49e15be2018-05-16 16:58:29 +010029import { DialogService } from '../../app/fw/layer/dialog.service';
30import { EeService } from '../../app/fw/util/ee.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010031import { FnService } from '../../app/fw/util/fn.service';
Sean Condon49e15be2018-05-16 16:58:29 +010032import { GlyphService } from '../../app/fw/svg/glyph.service';
33import { IconService } from '../../app/fw/svg/icon.service';
34import { KeyService } from '../../app/fw/util/key.service';
35import { LionService } from '../../app/fw/util/lion.service';
36import { NavService } from '../../app/fw/nav/nav.service';
37import { OnosService } from '../../app/onos.service';
38import { PanelService } from '../../app/fw/layer/panel.service';
39import { QuickHelpService } from '../../app/fw/layer/quickhelp.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010040import { SvgUtilService } from '../../app/fw/svg/svgutil.service';
Sean Condon49e15be2018-05-16 16:58:29 +010041import { ThemeService } from '../../app/fw/util/theme.service';
42import { SpriteService } from '../../app/fw/svg/sprite.service';
Sean Condonfd6d11b2018-06-02 20:29:49 +010043import { WebSocketService, WsOptions } from '../../app/fw/remote/websocket.service';
44
45class MockActivatedRoute extends ActivatedRoute {
46 constructor(params: Params) {
47 super();
48 this.queryParams = of(params);
49 }
50}
Sean Condon49e15be2018-05-16 16:58:29 +010051
52class MockDialogService {}
53
54class MockEeService {}
55
Sean Condon49e15be2018-05-16 16:58:29 +010056class MockGlyphService {}
57
58class MockIconService {}
59
60class MockKeyService {}
61
Sean Condon49e15be2018-05-16 16:58:29 +010062class MockNavService {}
63
64class MockOnosService {}
65
66class MockPanelService {}
67
68class MockQuickHelpService {}
69
70class MockSpriteService {}
71
72class MockThemeService {}
73
Sean Condonfd6d11b2018-06-02 20:29:49 +010074class MockVeilComponent {}
Sean Condon83fc39f2018-04-19 18:56:13 +010075
76/**
77 * ONOS GUI -- Onos Component - Unit Tests
78 */
79describe('OnosComponent', () => {
Sean Condon49e15be2018-05-16 16:58:29 +010080 let log: LogService;
Sean Condonfd6d11b2018-06-02 20:29:49 +010081 let fs: FnService;
82 let ar: MockActivatedRoute;
83 let windowMock: Window;
Sean Condon49e15be2018-05-16 16:58:29 +010084
85 beforeEach(async(() => {
86 log = new ConsoleLoggerService();
Sean Condonfd6d11b2018-06-02 20:29:49 +010087 ar = new MockActivatedRoute({'debug': 'TestService'});
88
89 windowMock = <any>{
90 location: <any> {
91 hostname: '',
92 host: '',
93 port: '',
94 protocol: '',
95 search: { debug: 'true'},
96 href: ''
97 },
98 innerHeight: 240,
99 innerWidth: 320
100 };
101 fs = new FnService(ar, log, windowMock);
Sean Condon49e15be2018-05-16 16:58:29 +0100102
103 TestBed.configureTestingModule({
104 declarations: [
105 IconComponent,
106 MastComponent,
107 NavComponent,
108 OnosComponent,
Sean Condonfd6d11b2018-06-02 20:29:49 +0100109 VeilComponent,
Sean Condon49e15be2018-05-16 16:58:29 +0100110 RouterOutlet
111 ],
112 providers: [
113 { provide: ChildrenOutletContexts, useClass: ChildrenOutletContexts },
114 { provide: DialogService, useClass: MockDialogService },
115 { provide: EeService, useClass: MockEeService },
Sean Condonfd6d11b2018-06-02 20:29:49 +0100116 { provide: FnService, useValue: fs },
Sean Condon49e15be2018-05-16 16:58:29 +0100117 { provide: GlyphService, useClass: MockGlyphService },
118 { provide: IconService, useClass: MockIconService },
119 { provide: KeyService, useClass: MockKeyService },
Sean Condon49e15be2018-05-16 16:58:29 +0100120 { provide: LogService, useValue: log },
121 { provide: NavService, useClass: MockNavService },
122 { provide: OnosService, useClass: MockOnosService },
123 { provide: QuickHelpService, useClass: MockQuickHelpService },
124 { provide: PanelService, useClass: MockPanelService },
125 { provide: SpriteService, useClass: MockSpriteService },
126 { provide: ThemeService, useClass: MockThemeService },
Sean Condonfd6d11b2018-06-02 20:29:49 +0100127 { provide: Window, useFactory: (() => windowMock ) },
Sean Condon49e15be2018-05-16 16:58:29 +0100128 ]
129 }).compileComponents();
130 }));
131
132 it('should create the app', async(() => {
133 const fixture = TestBed.createComponent(OnosComponent);
134 const app = fixture.debugElement.componentInstance;
135 expect(app).toBeTruthy();
136 }));
137
138 it(`should have as title 'onos'`, async(() => {
139 const fixture = TestBed.createComponent(OnosComponent);
140 const app = fixture.debugElement.componentInstance;
141 expect(app.title).toEqual('onos');
142 }));
Sean Condon83fc39f2018-04-19 18:56:13 +0100143});