Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 1 | /* |
| 2 | ============LICENSE_START========================================== |
| 3 | =================================================================== |
| 4 | Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. |
Arundathi Patil | bded4b1 | 2018-07-31 14:25:02 +0530 | [diff] [blame] | 5 | |
| 6 | Modification Copyright (C) 2018 IBM. |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 7 | =================================================================== |
| 8 | |
| 9 | Unless otherwise specified, all software contained herein is licensed |
| 10 | under the Apache License, Version 2.0 (the License); |
| 11 | you may not use this software except in compliance with the License. |
| 12 | You may obtain a copy of the License at |
| 13 | |
| 14 | http://www.apache.org/licenses/LICENSE-2.0 |
| 15 | |
| 16 | Unless required by applicable law or agreed to in writing, software |
| 17 | distributed under the License is distributed on an "AS IS" BASIS, |
| 18 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 19 | See the License for the specific language governing permissions and |
| 20 | limitations under the License. |
| 21 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 22 | ============LICENSE_END============================================ |
| 23 | */ |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 24 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 25 | import { async, ComponentFixture, TestBed, inject, tick, fakeAsync } from '@angular/core/testing'; |
| 26 | import { Http, HttpModule, ConnectionBackend, BaseRequestOptions, Response, ResponseOptions } from '@angular/http'; |
| 27 | import { MockBackend } from '@angular/http/testing'; |
Arundathi Patil | c01870a | 2019-09-03 14:31:49 +0530 | [diff] [blame^] | 28 | import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 29 | import { Observable } from 'rxjs/Observable'; |
Arundathi Patil | c01870a | 2019-09-03 14:31:49 +0530 | [diff] [blame^] | 30 | import { NO_ERRORS_SCHEMA, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 31 | import 'rxjs/add/observable/from'; |
| 32 | import 'rxjs/add/observable/empty'; |
| 33 | import 'rxjs/add/observable/of'; |
Arundathi Patil | bded4b1 | 2018-07-31 14:25:02 +0530 | [diff] [blame] | 34 | import { SimpleNotificationsModule, NotificationsService } from 'angular2-notifications'; |
| 35 | import { DialogService } from 'ng2-bootstrap-modal'; |
Arundathi Patil | 569053f | 2018-08-30 15:15:09 +0530 | [diff] [blame] | 36 | import {UtilityService} from '../shared/services/utilityService/utility.service'; |
| 37 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 38 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 39 | import { AboutUsComponent } from './aboutus.component'; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 40 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 41 | class MockService { |
| 42 | doStuff() { |
| 43 | return this; |
Arundathi Patil | c01870a | 2019-09-03 14:31:49 +0530 | [diff] [blame^] | 44 | }NoopAnimationsModule |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 45 | get() { |
| 46 | return Observable.of(new Response( |
| 47 | new ResponseOptions({ |
| 48 | body: "some data" |
| 49 | } |
| 50 | ))); |
| 51 | } |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 52 | } |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 53 | |
Arundathi Patil | c01870a | 2019-09-03 14:31:49 +0530 | [diff] [blame^] | 54 | fdescribe('ContacUsComponent', () => { |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 55 | let component: AboutUsComponent; |
| 56 | let fixture: ComponentFixture<AboutUsComponent>; |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 57 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 58 | beforeEach(async(() => { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 59 | let http = new MockService(); |
| 60 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 61 | TestBed.configureTestingModule({ |
Arundathi Patil | c01870a | 2019-09-03 14:31:49 +0530 | [diff] [blame^] | 62 | schemas: [ |
| 63 | CUSTOM_ELEMENTS_SCHEMA, |
| 64 | NO_ERRORS_SCHEMA |
| 65 | ], |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 66 | declarations: [AboutUsComponent], |
Arundathi Patil | bded4b1 | 2018-07-31 14:25:02 +0530 | [diff] [blame] | 67 | imports: [HttpModule, NgbModule.forRoot(), SimpleNotificationsModule.forRoot()], |
Arundathi Patil | 569053f | 2018-08-30 15:15:09 +0530 | [diff] [blame] | 68 | providers: [NgbModule, DialogService, UtilityService, { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 69 | provide: Http, useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => { |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 70 | return new Http(backend, defaultOptions); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 71 | }, deps: [MockBackend, BaseRequestOptions] |
| 72 | }, |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 73 | { provide: MockBackend, useClass: MockBackend }, |
| 74 | { provide: BaseRequestOptions, useClass: BaseRequestOptions }, |
| 75 | { provide: Http, useValue: http }] |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 76 | }).compileComponents(); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 77 | })); |
| 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 | }); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 88 | |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 89 | it('should open modal', inject([NgbModule, Http], (ngbModule: NgbModule, http: Http) => { |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 90 | let content = 'test'; |
Arundathi Patil | 429ef4f | 2019-08-05 17:28:48 +0530 | [diff] [blame] | 91 | component.versionLogFile(); |
| 92 | expect(component.data.text()).toBe('some data'); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 93 | })); |
| 94 | |
| 95 | it('should download log file', () => { |
| 96 | var blob = new Blob(['test'], { |
| 97 | type: 'text/plain;charset=utf-8' |
| 98 | }); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 99 | component.downloadLogFile(); |
| 100 | }); |
Arundathi Patil | a408395 | 2018-09-04 12:04:16 +0530 | [diff] [blame] | 101 | |
| 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 Patil | 8bee05c | 2018-09-12 16:38:03 +0530 | [diff] [blame] | 113 | |
| 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 Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 127 | }); |