2 * ========================LICENSE_START=================================
5 * Copyright (C) 2019 Nordix Foundation
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===================================
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";
28 import { NotificationService } from "@services/ui/notification.service";
29 import { PolicyControlComponent } from "./policy-control.component";
30 import { PolicyTypeDataSource } from "@policy/policy-type/policy-type.datasource";
31 import { UiService } from "@services/ui/ui.service";
32 import { PolicyTypeSchema } from "@interfaces/policy.types";
33 import { PolicyService } from '../services/policy/policy.service';
35 describe("PolicyControlComponent", () => {
36 let component: PolicyControlComponent;
37 let fixture: ComponentFixture<PolicyControlComponent>;
39 beforeEach(async(() => {
40 const policyTypeDataSourceSpy = jasmine.createSpyObj(
41 "PolicyTypeDataSource",
42 ["connect", "getPolicyTypes", "disconnect"]
44 const policyServiceSpy = jasmine.createSpyObj('PolicyService', ['getPolicyTypes']);
45 var policyTypeSchema = {} as PolicyTypeSchema;
46 policyTypeSchema.name = "";
47 policyTypeSchema.schemaObject = "";
48 policyTypeDataSourceSpy.connect.and.returnValue(of([policyTypeSchema]));
49 policyTypeDataSourceSpy.disconnect();
50 policyServiceSpy.getPolicyTypes.and.returnValue(of(["type1"]));
52 let matDialogStub: Partial<MatDialog>;
53 let notificationServiceStub: Partial<NotificationService>;
55 TestBed.configureTestingModule({
56 imports: [MatIconModule, MatTableModule, BrowserAnimationsModule],
57 schemas: [CUSTOM_ELEMENTS_SCHEMA],
58 declarations: [PolicyControlComponent],
60 { provide : PolicyService, useValue: policyServiceSpy},
61 { provide: PolicyTypeDataSource, useValue: policyTypeDataSourceSpy },
62 { provide: MatDialog, useValue: matDialogStub },
63 { provide: NotificationService, useValue: notificationServiceStub },
66 }).compileComponents();
70 fixture = TestBed.createComponent(PolicyControlComponent);
71 component = fixture.componentInstance;
72 fixture.detectChanges();
75 it("should create", () => {
76 expect(component).toBeTruthy();