CI: Migrate Sonar Scan job to GHA
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / ei-coordinator / producers-list / producers-list.component.spec.ts
index d7542e8..2b29dc9 100644 (file)
@@ -1,3 +1,22 @@
+/*-
+ * ========================LICENSE_START=================================
+ * O-RAN-SC
+ * %%
+ * Copyright (C) 2021-2022 Nordix Foundation
+ * %%
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================LICENSE_END===================================
+ */
 
 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed';
@@ -73,8 +92,10 @@ describe('ProducersListComponent', () => {
       } as Producer;
 
       setServiceSpy();
+
       component.loadProducers();
       const actualProducers: Producer[] = component.producers();
+      expect(actualProducers.length).toEqual(2);
       expect(actualProducers).toEqual([producer1, producer2]);
     });
 
@@ -105,7 +126,6 @@ describe('ProducersListComponent', () => {
 
     it('should contain data after initialization', async () => {
       setServiceSpy();
-      component.ngOnInit();
       const expectedProducerRows = [
         expectedProducer1Row,
         { id: 'producer2', types: 'type2,type3', status: 'DISABLED' }
@@ -127,8 +147,8 @@ describe('ProducersListComponent', () => {
       producerServiceSpy.getProducer.and.returnValues(of({} as ProducerRegistrationInfo));
       producerServiceSpy.getProducerStatus.and.returnValues(of({} as ProducerStatus));
 
-      component.ngOnInit();
       const expectedProducerRow = { id: 'producer1', types: '< No types >', status: '< No status >' };
+
       let producersTable = await loader.getHarness(MatTableHarness.with({ selector: '#producersTable' }));
       let producerRows = await producersTable.getRows();
       expect(await producerRows[0].getCellTextByColumnName()).toEqual(expectedProducerRow);
@@ -136,7 +156,6 @@ describe('ProducersListComponent', () => {
 
     it('filtering', async () => {
       setServiceSpy();
-      component.ngOnInit();
       let producersTable = await loader.getHarness(MatTableHarness.with({ selector: '#producersTable' }));
 
       let idFilterInput = await loader.getHarness(MatInputHarness.with({ selector: '#producerIdFilter' }));