blob: 5656942fe89cf63b8e3075ecf40f6a9042a601d9 [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 Patilc01870a2019-09-03 14:31:49 +053028import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
sj108sf1e61ce2018-03-13 20:29:58 +053029import { Observable } from 'rxjs/Observable';
Arundathi Patilc01870a2019-09-03 14:31:49 +053030import { NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
sj108sf1e61ce2018-03-13 20:29:58 +053031import 'rxjs/add/observable/from';
32import 'rxjs/add/observable/empty';
33import 'rxjs/add/observable/of';
Arundathi Patilbded4b12018-07-31 14:25:02 +053034import { SimpleNotificationsModule, NotificationsService } from 'angular2-notifications';
35import { DialogService } from 'ng2-bootstrap-modal';
Arundathi Patil569053f2018-08-30 15:15:09 +053036import {UtilityService} from '../shared/services/utilityService/utility.service';
37
Skip Wonnell2c977e22018-03-01 08:30:15 -060038
sj108sf1e61ce2018-03-13 20:29:58 +053039import { AboutUsComponent } from './aboutus.component';
Skip Wonnell2c977e22018-03-01 08:30:15 -060040
sj108sf1e61ce2018-03-13 20:29:58 +053041class MockService {
42 doStuff() {
43 return this;
Arundathi Patilc01870a2019-09-03 14:31:49 +053044 }NoopAnimationsModule
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053045 get() {
46 return Observable.of(new Response(
47 new ResponseOptions({
48 body: "some data"
49 }
50 )));
51 }
sj108sf1e61ce2018-03-13 20:29:58 +053052}
Skip Wonnell2c977e22018-03-01 08:30:15 -060053
Arundathi Patilc01870a2019-09-03 14:31:49 +053054fdescribe('ContacUsComponent', () => {
Skip Wonnell2c977e22018-03-01 08:30:15 -060055 let component: AboutUsComponent;
56 let fixture: ComponentFixture<AboutUsComponent>;
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053057
Skip Wonnell2c977e22018-03-01 08:30:15 -060058 beforeEach(async(() => {
sj108sf1e61ce2018-03-13 20:29:58 +053059 let http = new MockService();
60
Skip Wonnell2c977e22018-03-01 08:30:15 -060061 TestBed.configureTestingModule({
Arundathi Patilc01870a2019-09-03 14:31:49 +053062 schemas: [
63 CUSTOM_ELEMENTS_SCHEMA,
64 NO_ERRORS_SCHEMA
65 ],
sj108sf1e61ce2018-03-13 20:29:58 +053066 declarations: [AboutUsComponent],
Arundathi Patilbded4b12018-07-31 14:25:02 +053067 imports: [HttpModule, NgbModule.forRoot(), SimpleNotificationsModule.forRoot()],
Arundathi Patil569053f2018-08-30 15:15:09 +053068 providers: [NgbModule, DialogService, UtilityService, {
sj108sf1e61ce2018-03-13 20:29:58 +053069 provide: Http, useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053070 return new Http(backend, defaultOptions);
sj108sf1e61ce2018-03-13 20:29:58 +053071 }, deps: [MockBackend, BaseRequestOptions]
72 },
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053073 { provide: MockBackend, useClass: MockBackend },
74 { provide: BaseRequestOptions, useClass: BaseRequestOptions },
75 { provide: Http, useValue: http }]
sj108sf27d5542018-04-02 14:46:25 +053076 }).compileComponents();
Skip Wonnell2c977e22018-03-01 08:30:15 -060077 }));
78
79 beforeEach(() => {
80 fixture = TestBed.createComponent(AboutUsComponent);
81 component = fixture.componentInstance;
82 fixture.detectChanges();
83 });
84
85 it('should create', () => {
86 expect(component).toBeTruthy();
87 });
sj108sf1e61ce2018-03-13 20:29:58 +053088
Arundathi Patil30c6c5b2018-08-02 14:35:40 +053089 it('should open modal', inject([NgbModule, Http], (ngbModule: NgbModule, http: Http) => {
sj108sf27d5542018-04-02 14:46:25 +053090 let content = 'test';
Arundathi Patil429ef4f2019-08-05 17:28:48 +053091 component.versionLogFile();
92 expect(component.data.text()).toBe('some data');
sj108sf1e61ce2018-03-13 20:29:58 +053093 }));
94
95 it('should download log file', () => {
96 var blob = new Blob(['test'], {
97 type: 'text/plain;charset=utf-8'
98 });
sj108sf1e61ce2018-03-13 20:29:58 +053099 component.downloadLogFile();
100 });
Arundathi Patila4083952018-09-04 12:04:16 +0530101
102 it('should test tlPlus function', inject([UtilityService], (utilService: UtilityService) => {
103 let spy1 = spyOn(UtilityService.prototype, 'getTracelvl');
104 component.tlPlus();
105 expect(spy1).toHaveBeenCalled();
106 }));
107
108 it('should test tlMinus function', inject([UtilityService], (utilService: UtilityService) => {
109 let spy1 = spyOn(UtilityService.prototype, 'getTracelvl');
110 component.tlMinus();
111 expect(spy1).toHaveBeenCalled();
112 }));
Arundathi Patil8bee05c2018-09-12 16:38:03 +0530113
114 it('should test tlPlus function to call setTracelvl ', inject([UtilityService], (utilService: UtilityService) => {
115 let spy1 = spyOn(UtilityService.prototype, 'setTracelvl');
116 component.tlPlus();
117 expect(spy1).toHaveBeenCalled();
118 }));
119
120 it('should test tlMinus function to call setTracelvl', inject([UtilityService], (utilService: UtilityService) => {
121 let spy1 = spyOn(UtilityService.prototype, 'setTracelvl');
122 let trv = 4;
123 localStorage["Tracelvl"] = trv;
124 component.tlMinus();
125 expect(spy1).toHaveBeenCalled();
126 }));
Skip Wonnell2c977e22018-03-01 08:30:15 -0600127});