blob: 06715cdbe9ac7a4c88b6ac513de1228b6d59c292 [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 */
Sean Condon49e15be2018-05-16 16:58:29 +010016import { TestBed, inject } from '@angular/core/testing';
17
Sean Condon83fc39f2018-04-19 18:56:13 +010018import { LogService } from '../../app/log.service';
Sean Condon49e15be2018-05-16 16:58:29 +010019import { ConsoleLoggerService } from '../../app/consolelogger.service';
20import { DetectBrowserDirective } from '../../app/detectbrowser.directive';
21import { ActivatedRoute, Params } from '@angular/router';
Sean Condon83fc39f2018-04-19 18:56:13 +010022import { FnService } from '../../app/fw/util/fn.service';
23import { OnosService } from '../../app/onos.service';
Sean Condon49e15be2018-05-16 16:58:29 +010024import { of } from 'rxjs';
Sean Condon83fc39f2018-04-19 18:56:13 +010025
Sean Condon49e15be2018-05-16 16:58:29 +010026class MockFnService extends FnService {
27 constructor(ar: ActivatedRoute, log: LogService) {
28 super(ar, log);
29 }
Sean Condon83fc39f2018-04-19 18:56:13 +010030}
31
Sean Condon49e15be2018-05-16 16:58:29 +010032class MockOnosService {}
33
34class MockActivatedRoute extends ActivatedRoute {
35 constructor(params: Params) {
36 super();
37 this.queryParams = of(params);
38 }
Sean Condon83fc39f2018-04-19 18:56:13 +010039}
40
41/**
42 * ONOS GUI -- Detect Browser Directive - Unit Tests
43 */
44describe('DetectBrowserDirective', () => {
Sean Condon83fc39f2018-04-19 18:56:13 +010045 let log: LogService;
46 let ar: ActivatedRoute;
Sean Condon83fc39f2018-04-19 18:56:13 +010047
48 beforeEach(() => {
Sean Condon49e15be2018-05-16 16:58:29 +010049 log = new ConsoleLoggerService();
50 ar = new MockActivatedRoute(['debug', 'DetectBrowserDirective']);
51
52 TestBed.configureTestingModule({
53 providers: [ DetectBrowserDirective,
54 { provide: FnService, useValue: new MockFnService(ar, log) },
55 { provide: LogService, useValue: log },
56 { provide: OnosService, useClass: MockOnosService },
57 { provide: Document, useValue: document },
58 ]
59 });
Sean Condon83fc39f2018-04-19 18:56:13 +010060 });
61
62 afterEach(() => {
Sean Condon83fc39f2018-04-19 18:56:13 +010063 log = null;
Sean Condon83fc39f2018-04-19 18:56:13 +010064 });
65
Sean Condon49e15be2018-05-16 16:58:29 +010066 it('should create an instance', inject([DetectBrowserDirective], (directive: DetectBrowserDirective) => {
Sean Condon83fc39f2018-04-19 18:56:13 +010067 expect(directive).toBeTruthy();
Sean Condon49e15be2018-05-16 16:58:29 +010068 }));
Sean Condon83fc39f2018-04-19 18:56:13 +010069});