2140e0ae20051a34eb4a01a522dfa52dc8a0200e
[portal/sdk.git] /
1
2 /*
3  * ============LICENSE_START==========================================
4  * ONAP Portal SDK
5  * ===================================================================
6  * Copyright © 2019 AT&T Intellectual Property. All rights reserved.
7  * ===================================================================
8  * Modification Copyright © 2020 IBM.
9  * ===================================================================
10  *
11  * Unless otherwise specified, all software contained herein is licensed
12  * under the Apache License, Version 2.0 (the "License");
13  * you may not use this software except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  *             http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * limitations under the License.
21  *
22  * ============LICENSE_END============================================
23  *
24  * 
25  */
26 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
27 import { SearchComponent } from './search.component';
28 import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core';
29 import { MatTableModule, MatTableDataSource, MatMenuModule, MatSortModule, MatPaginatorModule } from '@angular/material';
30 import { HttpClientTestingModule } from '@angular/common/http/testing';
31 import { NoopAnimationsModule } from '@angular/platform-browser/animations';
32 import { RouterTestingModule } from '@angular/router/testing';
33 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
34 import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap';
35 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
36 import { NgbModalBackdrop } from '@ng-bootstrap/ng-bootstrap/modal/modal-backdrop';
37 import { NgModel } from '@angular/forms';
38 describe('SearchComponent', () => {
39   let component: SearchComponent;
40   let fixture: ComponentFixture<SearchComponent>;
41   beforeEach(async(() => {
42     TestBed.configureTestingModule({
43       schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA],
44       declarations: [ SearchComponent , ConfirmationModalComponent],
45       imports: [NoopAnimationsModule,
46         MatPaginatorModule,
47         MatSortModule,
48         MatTableModule,
49         MatMenuModule,
50         HttpClientTestingModule,
51         RouterTestingModule,
52       ]
53     })
54     .compileComponents();
55   })); 
56   beforeEach(() => {
57     fixture = TestBed.createComponent(SearchComponent);
58     component = fixture.componentInstance;
59     fixture.detectChanges();
60   });
61   it('should create', () => {
62     expect(component).toBeTruthy();
63   });
64   it('should test getUsers method', () => {
65       component.getUsers();
66       expect(component.showSpinner).toEqual(true);
67       let response;
68       component.response.subscribe(data => {
69           expect(response).toEqual(data);
70           expect(component.result).toEqual(JSON.parse(response.data));
71           expect(component.profileList).toEqual(JSON.parse(component.result.profileList));
72           expect(component.dataSource).toEqual(new MatTableDataSource(component.profileList));
73           expect(component.dataSource.paginator).toEqual(component.paginator);
74           expect(component.dataSource.sort).toEqual(component.sort);
75           expect(component.showSpinner).toEqual(false);
76       });   
77   });
78   // it('should test applyFilter method', () => {
79   //   let filterValue = "test"
80   //   component.applyFilter(filterValue);
81   //   expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase());
82   // });
83 });