blob: a30090ee08c76348ecdb4bb5b57ba0e759074457 [file] [log] [blame]
Sean Condona36f65c2019-05-20 08:21:41 +01001/*
2 * Copyright ${year}-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';
17
Sean Condon13f42b72019-05-31 16:17:52 +010018import { ${appNameTitle}Component } from './${artifactId}.component';
19import { WelcomeComponent } from '../welcome/welcome.component';
Sean Condon27f06da2019-05-25 17:02:14 +010020import {ActivatedRoute, Params} from '@angular/router';
Sean Condon13f42b72019-05-31 16:17:52 +010021import {CommonModule} from '@angular/common';
Sean Condon27f06da2019-05-25 17:02:14 +010022import { of } from 'rxjs';
23import { } from 'jasmine';
24import {
Sean Condon9c9b06c2019-06-06 15:41:42 +010025 Gui2FwLibModule,
Sean Condon27f06da2019-05-25 17:02:14 +010026 FnService,
27 IconService,
28 IconComponent,
29 LogService,
30 TableFilterPipe, LoadingComponent,
31} from 'gui2-fw-lib';
32import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
33import {FormsModule} from '@angular/forms';
34import {RouterTestingModule} from '@angular/router/testing';
35
36class MockActivatedRoute extends ActivatedRoute {
37 constructor(params: Params) {
38 super();
39 this.queryParams = of(params);
40 }
41}
42
43class MockIconService {
44 loadIconDef() { }
45}
Sean Condona36f65c2019-05-20 08:21:41 +010046
Sean Condon13f42b72019-05-31 16:17:52 +010047describe('${appNameTitle}Component', () => {
Sean Condon27f06da2019-05-25 17:02:14 +010048 let fs: FnService;
49 let ar: MockActivatedRoute;
50 let windowMock: Window;
51 let logServiceSpy: jasmine.SpyObj<LogService>;
Sean Condon13f42b72019-05-31 16:17:52 +010052 let component: ${appNameTitle}Component;
53 let fixture: ComponentFixture<${appNameTitle}Component>;
Sean Condona36f65c2019-05-20 08:21:41 +010054
55 beforeEach(async(() => {
Sean Condon27f06da2019-05-25 17:02:14 +010056 const logSpy = jasmine.createSpyObj('LogService', ['info', 'debug', 'warn', 'error']);
57 ar = new MockActivatedRoute({ 'debug': 'txrx' });
58
59 windowMock = <any>{
60 location: <any>{
61 hostname: 'foo',
62 host: 'foo',
63 port: '80',
64 protocol: 'http',
65 search: { debug: 'true' },
66 href: 'ws://foo:123/onos/ui/websock/path',
67 absUrl: 'ws://foo:123/onos/ui/websock/path'
68 }
69 };
70 fs = new FnService(ar, logSpy, windowMock);
71
Sean Condona36f65c2019-05-20 08:21:41 +010072 TestBed.configureTestingModule({
Sean Condon9c9b06c2019-06-06 15:41:42 +010073 imports: [
74 BrowserAnimationsModule,
75 CommonModule,
76 FormsModule,
77 RouterTestingModule,
78 Gui2FwLibModule
79 ],
Sean Condon13f42b72019-05-31 16:17:52 +010080 declarations: [
81 ${appNameTitle}Component,
82 WelcomeComponent
83 ],
Sean Condon27f06da2019-05-25 17:02:14 +010084 providers: [
85 { provide: FnService, useValue: fs },
86 { provide: LogService, useValue: logSpy },
87 { provide: IconService, useClass: MockIconService },
88 { provide: 'Window', useValue: windowMock },
89 ]
Sean Condona36f65c2019-05-20 08:21:41 +010090 })
91 .compileComponents();
Sean Condon27f06da2019-05-25 17:02:14 +010092 logServiceSpy = TestBed.get(LogService);
Sean Condona36f65c2019-05-20 08:21:41 +010093 }));
94
95 beforeEach(() => {
Sean Condon13f42b72019-05-31 16:17:52 +010096 fixture = TestBed.createComponent(${appNameTitle}Component);
Sean Condona36f65c2019-05-20 08:21:41 +010097 component = fixture.componentInstance;
98 fixture.detectChanges();
99 });
100
101 it('should create', () => {
102 expect(component).toBeTruthy();
103 });
104});