blob: af54b2b3f012f4b77b5b8eb8ba58277671b0960e [file] [log] [blame]
Skip Wonnell2c977e22018-03-01 08:30:15 -06001/*
2============LICENSE_START==========================================
3===================================================================
4Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
Arundathi Patilbded4b12018-07-31 14:25:02 +05305
6Modification Copyright (C) 2018 IBM.
Skip Wonnell2c977e22018-03-01 08:30:15 -06007===================================================================
8
9Unless otherwise specified, all software contained herein is licensed
10under the Apache License, Version 2.0 (the License);
11you may not use this software except in compliance with the License.
12You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing, software
17distributed under the License is distributed on an "AS IS" BASIS,
18WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19See the License for the specific language governing permissions and
20limitations under the License.
21
Skip Wonnell2c977e22018-03-01 08:30:15 -060022============LICENSE_END============================================
23*/
sj108sf27d5542018-04-02 14:46:25 +053024
sj108sf1e61ce2018-03-13 20:29:58 +053025import { async, ComponentFixture, TestBed, inject, tick, fakeAsync } from '@angular/core/testing';
26import { Http, HttpModule, ConnectionBackend, BaseRequestOptions, Response, ResponseOptions } from '@angular/http';
27import { MockBackend } from '@angular/http/testing';
Arundathi Patilbded4b12018-07-31 14:25:02 +053028import { ModalDismissReasons, NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap';
sj108sf1e61ce2018-03-13 20:29:58 +053029import { Observable } from 'rxjs/Observable';
30import 'rxjs/add/observable/from';
31import 'rxjs/add/observable/empty';
32import 'rxjs/add/observable/of';
Arundathi Patilbded4b12018-07-31 14:25:02 +053033import { SimpleNotificationsModule, NotificationsService } from 'angular2-notifications';
34import { DialogService } from 'ng2-bootstrap-modal';
Arundathi Patil569053f2018-08-30 15:15:09 +053035import {UtilityService} from '../shared/services/utilityService/utility.service';
36
Skip Wonnell2c977e22018-03-01 08:30:15 -060037
sj108sf1e61ce2018-03-13 20:29:58 +053038import { AboutUsComponent } from './aboutus.component';
Skip Wonnell2c977e22018-03-01 08:30:15 -060039
sj108sf1e61ce2018-03-13 20:29:58 +053040class MockService {
41 doStuff() {
42 return this;
43 }
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053044 get() {
45 return Observable.of(new Response(
46 new ResponseOptions({
47 body: "some data"
48 }
49 )));
50 }
sj108sf1e61ce2018-03-13 20:29:58 +053051}
Skip Wonnell2c977e22018-03-01 08:30:15 -060052
53describe('ContacUsComponent', () => {
54 let component: AboutUsComponent;
55 let fixture: ComponentFixture<AboutUsComponent>;
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053056
Skip Wonnell2c977e22018-03-01 08:30:15 -060057 beforeEach(async(() => {
sj108sf1e61ce2018-03-13 20:29:58 +053058 let http = new MockService();
59
Skip Wonnell2c977e22018-03-01 08:30:15 -060060 TestBed.configureTestingModule({
sj108sf1e61ce2018-03-13 20:29:58 +053061 declarations: [AboutUsComponent],
Arundathi Patilbded4b12018-07-31 14:25:02 +053062 imports: [HttpModule, NgbModule.forRoot(), SimpleNotificationsModule.forRoot()],
Arundathi Patil569053f2018-08-30 15:15:09 +053063 providers: [NgbModule, DialogService, UtilityService, {
sj108sf1e61ce2018-03-13 20:29:58 +053064 provide: Http, useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053065 return new Http(backend, defaultOptions);
sj108sf1e61ce2018-03-13 20:29:58 +053066 }, deps: [MockBackend, BaseRequestOptions]
67 },
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053068 { provide: MockBackend, useClass: MockBackend },
69 { provide: BaseRequestOptions, useClass: BaseRequestOptions },
70 { provide: Http, useValue: http }]
sj108sf27d5542018-04-02 14:46:25 +053071 }).compileComponents();
Skip Wonnell2c977e22018-03-01 08:30:15 -060072 }));
73
74 beforeEach(() => {
75 fixture = TestBed.createComponent(AboutUsComponent);
76 component = fixture.componentInstance;
77 fixture.detectChanges();
78 });
79
80 it('should create', () => {
81 expect(component).toBeTruthy();
82 });
sj108sf1e61ce2018-03-13 20:29:58 +053083
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053084 it('should open modal', inject([NgbModule, Http], (ngbModule: NgbModule, http: Http) => {
sj108sf27d5542018-04-02 14:46:25 +053085 let content = 'test';
Arundathi Patil429ef4f2019-08-05 17:28:48 +053086 component.versionLogFile();
87 expect(component.data.text()).toBe('some data');
sj108sf1e61ce2018-03-13 20:29:58 +053088 }));
89
90 it('should download log file', () => {
91 var blob = new Blob(['test'], {
92 type: 'text/plain;charset=utf-8'
93 });
sj108sf1e61ce2018-03-13 20:29:58 +053094 component.downloadLogFile();
95 });
Arundathi Patila4083952018-09-04 12:04:16 +053096
97 it('should test tlPlus function', inject([UtilityService], (utilService: UtilityService) => {
98 let spy1 = spyOn(UtilityService.prototype, 'getTracelvl');
99 component.tlPlus();
100 expect(spy1).toHaveBeenCalled();
101 }));
102
103 it('should test tlMinus function', inject([UtilityService], (utilService: UtilityService) => {
104 let spy1 = spyOn(UtilityService.prototype, 'getTracelvl');
105 component.tlMinus();
106 expect(spy1).toHaveBeenCalled();
107 }));
Arundathi Patil8bee05c2018-09-12 16:38:03 +0530108
109 it('should test tlPlus function to call setTracelvl ', inject([UtilityService], (utilService: UtilityService) => {
110 let spy1 = spyOn(UtilityService.prototype, 'setTracelvl');
111 component.tlPlus();
112 expect(spy1).toHaveBeenCalled();
113 }));
114
115 it('should test tlMinus function to call setTracelvl', inject([UtilityService], (utilService: UtilityService) => {
116 let spy1 = spyOn(UtilityService.prototype, 'setTracelvl');
117 let trv = 4;
118 localStorage["Tracelvl"] = trv;
119 component.tlMinus();
120 expect(spy1).toHaveBeenCalled();
121 }));
Skip Wonnell2c977e22018-03-01 08:30:15 -0600122});