blob: 29f97848074f98241375896b9c5b6b2cca82940d [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 Patil30c6c5b2018-08-02 14:35:40 +053086 // component.open(content);
87 component.versionLogFile().subscribe((data) => {
Arundathi Patila856e082018-08-23 15:40:14 +053088 expect(data.text()).toBe('some data');
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053089 });
sj108sf1e61ce2018-03-13 20:29:58 +053090 }));
91
92 it('should download log file', () => {
93 var blob = new Blob(['test'], {
94 type: 'text/plain;charset=utf-8'
95 });
sj108sf1e61ce2018-03-13 20:29:58 +053096 component.downloadLogFile();
97 });
Arundathi Patila4083952018-09-04 12:04:16 +053098
99 it('should test tlPlus function', inject([UtilityService], (utilService: UtilityService) => {
100 let spy1 = spyOn(UtilityService.prototype, 'getTracelvl');
101 component.tlPlus();
102 expect(spy1).toHaveBeenCalled();
103 }));
104
105 it('should test tlMinus function', inject([UtilityService], (utilService: UtilityService) => {
106 let spy1 = spyOn(UtilityService.prototype, 'getTracelvl');
107 component.tlMinus();
108 expect(spy1).toHaveBeenCalled();
109 }));
Arundathi Patil8bee05c2018-09-12 16:38:03 +0530110
111 it('should test tlPlus function to call setTracelvl ', inject([UtilityService], (utilService: UtilityService) => {
112 let spy1 = spyOn(UtilityService.prototype, 'setTracelvl');
113 component.tlPlus();
114 expect(spy1).toHaveBeenCalled();
115 }));
116
117 it('should test tlMinus function to call setTracelvl', inject([UtilityService], (utilService: UtilityService) => {
118 let spy1 = spyOn(UtilityService.prototype, 'setTracelvl');
119 let trv = 4;
120 localStorage["Tracelvl"] = trv;
121 component.tlMinus();
122 expect(spy1).toHaveBeenCalled();
123 }));
Skip Wonnell2c977e22018-03-01 08:30:15 -0600124});