parameter-definition service- removed unused code
[appc/cdt.git] / src / app / about-us / aboutus.component.spec.ts
1 /*
2 ============LICENSE_START==========================================
3 ===================================================================
4 Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
5
6 Modification Copyright (C) 2018 IBM.
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
22 ============LICENSE_END============================================
23 */
24
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';
28 import { ModalDismissReasons, NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap';
29 import { Observable } from 'rxjs/Observable';
30 import 'rxjs/add/observable/from';
31 import 'rxjs/add/observable/empty';
32 import 'rxjs/add/observable/of';
33 import { SimpleNotificationsModule, NotificationsService } from 'angular2-notifications';
34 import { DialogService } from 'ng2-bootstrap-modal';
35
36 import { AboutUsComponent } from './aboutus.component';
37
38 class MockService {
39     doStuff() {
40         return this;
41     }
42     get() {
43         return Observable.of(new Response(
44             new ResponseOptions({
45                 body: "some data"
46               }
47             )));
48     }
49 }
50
51 describe('ContacUsComponent', () => {
52     let component: AboutUsComponent;
53     let fixture: ComponentFixture<AboutUsComponent>;
54
55     beforeEach(async(() => {
56         let http = new MockService();
57
58         TestBed.configureTestingModule({
59             declarations: [AboutUsComponent],
60             imports: [HttpModule, NgbModule.forRoot(), SimpleNotificationsModule.forRoot()],
61             providers: [NgbModule, DialogService, {
62                 provide: Http, useFactory: (backend: ConnectionBackend, defaultOptions: BaseRequestOptions) => {
63                     return new Http(backend, defaultOptions);
64                 }, deps: [MockBackend, BaseRequestOptions]
65             },
66                 { provide: MockBackend, useClass: MockBackend },
67                 { provide: BaseRequestOptions, useClass: BaseRequestOptions },
68                 { provide: Http, useValue: http }]
69         }).compileComponents();
70     }));
71
72     beforeEach(() => {
73         fixture = TestBed.createComponent(AboutUsComponent);
74         component = fixture.componentInstance;
75         fixture.detectChanges();
76     });
77
78     it('should create', () => {
79         expect(component).toBeTruthy();
80     });
81
82     it('should open modal', inject([NgbModule, Http], (ngbModule: NgbModule, http: Http) => {
83         let content = 'test';
84         // component.open(content);
85         component.versionLogFile().subscribe((data) => {
86             expect(data.text()).toBe('some data');
87         });
88     }));
89
90     it('should download log file', () => {
91         var blob = new Blob(['test'], {
92             type: 'text/plain;charset=utf-8'
93         });
94         component.downloadLogFile();
95     });
96 });