80c9d8c442feeae80d2c89246975998bf723817d
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / policy / policy-control.component.spec.ts
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2019 Nordix Foundation
6  * %%
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ========================LICENSE_END===================================
19  */
20 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
21 import { BrowserAnimationsModule } from '@angular/platform-browser/animations'
22 import { MatDialog } from '@angular/material/dialog';
23 import { MatIconModule } from '@angular/material/icon';
24 import { MatTableModule } from '@angular/material/table';
25 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
26 import { of } from 'rxjs';
27
28 import { NotificationService } from '../services/ui/notification.service';
29 import { PolicyControlComponent } from './policy-control.component';
30 import { PolicyTypeDataSource } from './policy-type/policy-type.datasource';
31 import { UiService } from '../services/ui/ui.service';
32 import { PolicyTypeSchema } from '../interfaces/policy.types';
33
34 describe('PolicyControlComponent', () => {
35   let component: PolicyControlComponent;
36   let fixture: ComponentFixture<PolicyControlComponent>;
37
38   beforeEach(async(() => {
39     const policyTypeDataSourceSpy = jasmine.createSpyObj('PolicyTypeDataSource', [ 'connect', 'getPolicyTypes',  'disconnect' ]);
40     var policyTypeSchema = {} as PolicyTypeSchema;
41     policyTypeSchema.name = '';
42     policyTypeSchema.schemaObject = '';
43     policyTypeDataSourceSpy.connect.and.returnValue(of([ policyTypeSchema]));
44     policyTypeDataSourceSpy.disconnect();
45
46     let matDialogStub: Partial<MatDialog>;
47     let notificationServiceStub: Partial<NotificationService>;
48
49     TestBed.configureTestingModule({
50       imports: [
51         MatIconModule,
52         MatTableModule,
53         BrowserAnimationsModule
54       ],
55       schemas: [
56         CUSTOM_ELEMENTS_SCHEMA
57       ],
58       declarations: [
59         PolicyControlComponent
60        ],
61       providers: [
62         { provide: PolicyTypeDataSource, useValue: policyTypeDataSourceSpy },
63         { provide: MatDialog, useValue: matDialogStub },
64         { provide: NotificationService, useValue: notificationServiceStub },
65         UiService
66        ]
67     })
68     .compileComponents();
69   }));
70
71   beforeEach(() => {
72     fixture = TestBed.createComponent(PolicyControlComponent);
73     component = fixture.componentInstance;
74     fixture.detectChanges();
75   });
76
77   it('should create', () => {
78     expect(component).toBeTruthy();
79   });
80 });