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 | bded4b1 | 2018-07-31 14:25:02 +0530 | [diff] [blame] | 28 | import { ModalDismissReasons, NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap'; |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 29 | import { Observable } from 'rxjs/Observable'; |
| 30 | import 'rxjs/add/observable/from'; |
| 31 | import 'rxjs/add/observable/empty'; |
| 32 | import 'rxjs/add/observable/of'; |
Arundathi Patil | bded4b1 | 2018-07-31 14:25:02 +0530 | [diff] [blame] | 33 | import { SimpleNotificationsModule, NotificationsService } from 'angular2-notifications'; |
| 34 | import { DialogService } from 'ng2-bootstrap-modal'; |
Arundathi Patil | 569053f | 2018-08-30 15:15:09 +0530 | [diff] [blame] | 35 | import {UtilityService} from '../shared/services/utilityService/utility.service'; |
| 36 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 37 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 38 | import { AboutUsComponent } from './aboutus.component'; |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 39 | |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 40 | class MockService { |
| 41 | doStuff() { |
| 42 | return this; |
| 43 | } |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 44 | get() { |
| 45 | return Observable.of(new Response( |
| 46 | new ResponseOptions({ |
| 47 | body: "some data" |
| 48 | } |
| 49 | ))); |
| 50 | } |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 51 | } |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 52 | |
| 53 | describe('ContacUsComponent', () => { |
| 54 | let component: AboutUsComponent; |
| 55 | let fixture: ComponentFixture<AboutUsComponent>; |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 56 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 57 | beforeEach(async(() => { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 58 | let http = new MockService(); |
| 59 | |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 60 | TestBed.configureTestingModule({ |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 61 | declarations: [AboutUsComponent], |
Arundathi Patil | bded4b1 | 2018-07-31 14:25:02 +0530 | [diff] [blame] | 62 | imports: [HttpModule, NgbModule.forRoot(), SimpleNotificationsModule.forRoot()], |
Arundathi Patil | 569053f | 2018-08-30 15:15:09 +0530 | [diff] [blame] | 63 | providers: [NgbModule, DialogService, UtilityService, { |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 64 | provide: Http, useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => { |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 65 | return new Http(backend, defaultOptions); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 66 | }, deps: [MockBackend, BaseRequestOptions] |
| 67 | }, |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 68 | { provide: MockBackend, useClass: MockBackend }, |
| 69 | { provide: BaseRequestOptions, useClass: BaseRequestOptions }, |
| 70 | { provide: Http, useValue: http }] |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 71 | }).compileComponents(); |
Skip Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 72 | })); |
| 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 | }); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 83 | |
Arundathi Patil | 30c6c5b | 2018-08-02 14:35:40 +0530 | [diff] [blame] | 84 | it('should open modal', inject([NgbModule, Http], (ngbModule: NgbModule, http: Http) => { |
sj108s | f27d554 | 2018-04-02 14:46:25 +0530 | [diff] [blame] | 85 | let content = 'test'; |
Arundathi Patil | 429ef4f | 2019-08-05 17:28:48 +0530 | [diff] [blame^] | 86 | component.versionLogFile(); |
| 87 | expect(component.data.text()).toBe('some data'); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 88 | })); |
| 89 | |
| 90 | it('should download log file', () => { |
| 91 | var blob = new Blob(['test'], { |
| 92 | type: 'text/plain;charset=utf-8' |
| 93 | }); |
sj108s | f1e61ce | 2018-03-13 20:29:58 +0530 | [diff] [blame] | 94 | component.downloadLogFile(); |
| 95 | }); |
Arundathi Patil | a408395 | 2018-09-04 12:04:16 +0530 | [diff] [blame] | 96 | |
| 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 Patil | 8bee05c | 2018-09-12 16:38:03 +0530 | [diff] [blame] | 108 | |
| 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 Wonnell | 2c977e2 | 2018-03-01 08:30:15 -0600 | [diff] [blame] | 122 | }); |