73914f1126a1fb34f0c6048551e5c647e578cb31
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / policy-control / 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, MatTableModule } from '@angular/material';
24 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
25 import { of } from 'rxjs';
26
27 import { NotificationService } from '../services/ui/notification.service';
28 import { PolicyControlComponent } from './policy-control.component';
29 import { PolicyTypeDataSource } from './policy-type.datasource';
30 import { UiService } from '../services/ui/ui.service';
31 import { PolicyTypeSchema } from '../interfaces/policy.types';
32
33 describe('PolicyControlComponent', () => {
34   let component: PolicyControlComponent;
35   let fixture: ComponentFixture<PolicyControlComponent>;
36
37   beforeEach(async(() => {
38     const policyTypeDataSourceSpy = jasmine.createSpyObj('PolicyTypeDataSource', [ 'connect', 'getPolicyTypes',  'disconnect' ]);
39     var policyTypeSchema = {} as PolicyTypeSchema;
40     policyTypeSchema.name = '';
41     policyTypeSchema.schemaObject = '';
42     policyTypeDataSourceSpy.connect.and.returnValue(of([ policyTypeSchema]));
43     policyTypeDataSourceSpy.disconnect();
44
45     let matDialogStub: Partial<MatDialog>;
46     let notificationServiceStub: Partial<NotificationService>;
47
48     TestBed.configureTestingModule({
49       imports: [
50         MatIconModule,
51         MatTableModule,
52         BrowserAnimationsModule
53       ],
54       schemas: [
55         CUSTOM_ELEMENTS_SCHEMA
56       ],
57       declarations: [
58         PolicyControlComponent
59        ],
60       providers: [
61         { provide: PolicyTypeDataSource, useValue: policyTypeDataSourceSpy },
62         { provide: MatDialog, useValue: matDialogStub },
63         { provide: NotificationService, useValue: notificationServiceStub },
64         UiService
65        ]
66     })
67     .compileComponents();
68   }));
69
70   beforeEach(() => {
71     fixture = TestBed.createComponent(PolicyControlComponent);
72     component = fixture.componentInstance;
73     fixture.detectChanges();
74   });
75
76   it('should create', () => {
77     expect(component).toBeTruthy();
78   });
79 });