Sean Condon | a36f65c | 2019-05-20 08:21:41 +0100 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; |
| 17 | |
Sean Condon | 13f42b7 | 2019-05-31 16:17:52 +0100 | [diff] [blame] | 18 | import { ${appNameTitle}Component } from './${artifactId}.component'; |
| 19 | import { WelcomeComponent } from '../welcome/welcome.component'; |
Sean Condon | 27f06da | 2019-05-25 17:02:14 +0100 | [diff] [blame] | 20 | import {ActivatedRoute, Params} from '@angular/router'; |
Sean Condon | 13f42b7 | 2019-05-31 16:17:52 +0100 | [diff] [blame] | 21 | import {CommonModule} from '@angular/common'; |
Sean Condon | 27f06da | 2019-05-25 17:02:14 +0100 | [diff] [blame] | 22 | import { of } from 'rxjs'; |
| 23 | import { } from 'jasmine'; |
| 24 | import { |
Sean Condon | 9c9b06c | 2019-06-06 15:41:42 +0100 | [diff] [blame^] | 25 | Gui2FwLibModule, |
Sean Condon | 27f06da | 2019-05-25 17:02:14 +0100 | [diff] [blame] | 26 | FnService, |
| 27 | IconService, |
| 28 | IconComponent, |
| 29 | LogService, |
| 30 | TableFilterPipe, LoadingComponent, |
| 31 | } from 'gui2-fw-lib'; |
| 32 | import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; |
| 33 | import {FormsModule} from '@angular/forms'; |
| 34 | import {RouterTestingModule} from '@angular/router/testing'; |
| 35 | |
| 36 | class MockActivatedRoute extends ActivatedRoute { |
| 37 | constructor(params: Params) { |
| 38 | super(); |
| 39 | this.queryParams = of(params); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | class MockIconService { |
| 44 | loadIconDef() { } |
| 45 | } |
Sean Condon | a36f65c | 2019-05-20 08:21:41 +0100 | [diff] [blame] | 46 | |
Sean Condon | 13f42b7 | 2019-05-31 16:17:52 +0100 | [diff] [blame] | 47 | describe('${appNameTitle}Component', () => { |
Sean Condon | 27f06da | 2019-05-25 17:02:14 +0100 | [diff] [blame] | 48 | let fs: FnService; |
| 49 | let ar: MockActivatedRoute; |
| 50 | let windowMock: Window; |
| 51 | let logServiceSpy: jasmine.SpyObj<LogService>; |
Sean Condon | 13f42b7 | 2019-05-31 16:17:52 +0100 | [diff] [blame] | 52 | let component: ${appNameTitle}Component; |
| 53 | let fixture: ComponentFixture<${appNameTitle}Component>; |
Sean Condon | a36f65c | 2019-05-20 08:21:41 +0100 | [diff] [blame] | 54 | |
| 55 | beforeEach(async(() => { |
Sean Condon | 27f06da | 2019-05-25 17:02:14 +0100 | [diff] [blame] | 56 | 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 Condon | a36f65c | 2019-05-20 08:21:41 +0100 | [diff] [blame] | 72 | TestBed.configureTestingModule({ |
Sean Condon | 9c9b06c | 2019-06-06 15:41:42 +0100 | [diff] [blame^] | 73 | imports: [ |
| 74 | BrowserAnimationsModule, |
| 75 | CommonModule, |
| 76 | FormsModule, |
| 77 | RouterTestingModule, |
| 78 | Gui2FwLibModule |
| 79 | ], |
Sean Condon | 13f42b7 | 2019-05-31 16:17:52 +0100 | [diff] [blame] | 80 | declarations: [ |
| 81 | ${appNameTitle}Component, |
| 82 | WelcomeComponent |
| 83 | ], |
Sean Condon | 27f06da | 2019-05-25 17:02:14 +0100 | [diff] [blame] | 84 | providers: [ |
| 85 | { provide: FnService, useValue: fs }, |
| 86 | { provide: LogService, useValue: logSpy }, |
| 87 | { provide: IconService, useClass: MockIconService }, |
| 88 | { provide: 'Window', useValue: windowMock }, |
| 89 | ] |
Sean Condon | a36f65c | 2019-05-20 08:21:41 +0100 | [diff] [blame] | 90 | }) |
| 91 | .compileComponents(); |
Sean Condon | 27f06da | 2019-05-25 17:02:14 +0100 | [diff] [blame] | 92 | logServiceSpy = TestBed.get(LogService); |
Sean Condon | a36f65c | 2019-05-20 08:21:41 +0100 | [diff] [blame] | 93 | })); |
| 94 | |
| 95 | beforeEach(() => { |
Sean Condon | 13f42b7 | 2019-05-31 16:17:52 +0100 | [diff] [blame] | 96 | fixture = TestBed.createComponent(${appNameTitle}Component); |
Sean Condon | a36f65c | 2019-05-20 08:21:41 +0100 | [diff] [blame] | 97 | component = fixture.componentInstance; |
| 98 | fixture.detectChanges(); |
| 99 | }); |
| 100 | |
| 101 | it('should create', () => { |
| 102 | expect(component).toBeTruthy(); |
| 103 | }); |
| 104 | }); |