[ACS-5620] stabilise unit tests by switching to standard Angular api (#8759)

* switch to standard TestBed api for unit testing

* test fixes

* test fixes

* test fixes

* test fixes

* test fixes

* test fixes

* test fixes

* test fixes

* test fixes
This commit is contained in:
Denys Vuika
2023-07-15 15:02:33 +01:00
committed by GitHub
parent 574bff2d8d
commit f45d69eb49
329 changed files with 3334 additions and 4050 deletions

View File

@@ -21,7 +21,6 @@ import { Chart } from '../../diagram/models/chart/chart.model';
import { ReportQuery } from '../../diagram/models/report/report-query.model';
import * as analyticMock from '../../mock';
import { AnalyticsGeneratorComponent } from '../components/analytics-generator.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -32,14 +31,13 @@ describe('AnalyticsGeneratorComponent', () => {
let component: any;
let fixture: ComponentFixture<AnalyticsGeneratorComponent>;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(AnalyticsGeneratorComponent);
component = fixture.componentInstance;

View File

@@ -17,7 +17,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AnalyticsReportHeatMapComponent } from '../components/analytics-report-heat-map.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -37,14 +36,13 @@ describe('AnalyticsReportHeatMapComponent', () => {
const totalTimeValues: any = { 'sid-fake-id': 1, 'fake-start-event': 4 };
const avgTimeValues: any = { 'sid-fake-id': 4, 'fake-start-event': 5 };
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(AnalyticsReportHeatMapComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

View File

@@ -18,7 +18,6 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AnalyticsReportListComponent, LAYOUT_GRID, LAYOUT_LIST } from '../components/analytics-report-list.component';
import { ReportParametersModel } from '../../diagram/models/report/report-parameters.model';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -40,14 +39,13 @@ describe('AnalyticsReportListComponent', () => {
let fixture: ComponentFixture<AnalyticsReportListComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(AnalyticsReportListComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

View File

@@ -20,7 +20,6 @@ import { ComponentFixture, fakeAsync, TestBed } from '@angular/core/testing';
import { ReportParametersModel } from '../../diagram/models/report/report-parameters.model';
import * as analyticParamsMock from '../../mock';
import { AnalyticsReportParametersComponent } from '../components/analytics-report-parameters.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { AnalyticsService } from '../services/analytics.service';
import { of } from 'rxjs';
@@ -36,14 +35,13 @@ describe('AnalyticsReportParametersComponent', () => {
let validForm = false;
let service: AnalyticsService;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(AnalyticsReportParametersComponent);
service = TestBed.inject(AnalyticsService);
component = fixture.componentInstance;

View File

@@ -1,44 +0,0 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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.
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AnalyticsComponent } from '../components/analytics.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
describe('AnalyticsComponent', () => {
let fixture: ComponentFixture<AnalyticsComponent>;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
fixture = TestBed.createComponent(AnalyticsComponent);
fixture.detectChanges();
});
it('should create component', () => {
expect(fixture.componentInstance).toBeDefined();
});
});

View File

@@ -18,7 +18,6 @@
import { TestBed } from '@angular/core/testing';
import { fakeReportList } from '../../mock';
import { AnalyticsService } from './analytics.service';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -28,14 +27,13 @@ describe('AnalyticsService', () => {
let service: AnalyticsService;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
service = TestBed.inject(AnalyticsService);
});

View File

@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as diagramsActivitiesMock from '../../mock/diagram/diagram-activities.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,14 +30,13 @@ describe('Diagrams activities', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

View File

@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as boundaryEventMock from '../../mock/diagram/diagram-boundary.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,14 +30,13 @@ describe('Diagrams boundary', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

View File

@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as intermediateCatchingMock from '../../mock/diagram/diagram-intermediate.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,14 +30,13 @@ describe('Diagrams Catching', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

View File

@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as diagramsEventsMock from '../../mock/diagram/diagram-events.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,21 +30,18 @@ describe('Diagrams events', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
fixture.detectChanges();
});
beforeEach(() => {
jasmine.Ajax.install();
component.processInstanceId = '38399';
component.processDefinitionId = 'fakeprocess:24:38399';

View File

@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as flowsMock from '../../mock/diagram/diagram-flows.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,14 +30,13 @@ describe('Diagrams flows', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;

View File

@@ -19,7 +19,6 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as diagramsGatewaysMock from '../../mock/diagram/diagram-gateways.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,21 +30,18 @@ describe('Diagrams gateways', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
fixture.detectChanges();
});
beforeEach(() => {
jasmine.Ajax.install();
component.processInstanceId = '38399';
component.processDefinitionId = 'fakeprocess:24:38399';

View File

@@ -16,10 +16,8 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as structuralMock from '../../mock/diagram/diagram-structural.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,21 +29,18 @@ describe('Diagrams structural', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
fixture.detectChanges();
});
beforeEach(() => {
jasmine.Ajax.install();
component.processInstanceId = '38399';
component.processDefinitionId = 'fakeprocess:24:38399';

View File

@@ -16,10 +16,8 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as swimLanesMock from '../../mock/diagram/diagram-swimlanes.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,21 +29,18 @@ describe('Diagrams swim', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
fixture = TestBed.createComponent(DiagramComponent);
component = fixture.componentInstance;
element = fixture.nativeElement;
fixture.detectChanges();
});
beforeEach(() => {
jasmine.Ajax.install();
component.processInstanceId = '38399';
component.processDefinitionId = 'fakeprocess:24:38399';

View File

@@ -16,10 +16,8 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import * as throwEventMock from '../../mock/diagram/diagram-throw.mock';
import { DiagramComponent } from './diagram.component';
import { setupTestBed } from '@alfresco/adf-core';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -31,14 +29,13 @@ describe('Diagrams throw', () => {
let fixture: ComponentFixture<DiagramComponent>;
let element: HTMLElement;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
jasmine.Ajax.install();
fixture = TestBed.createComponent(DiagramComponent);

View File

@@ -19,7 +19,6 @@ import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { DiagramTooltipComponent } from './diagram-tooltip.component';
import { setupTestBed } from '@alfresco/adf-core';
@Component({
template: `
@@ -40,11 +39,10 @@ describe('DiagramTooltipComponent', () => {
let component: DiagramTooltipComponent;
let data;
setupTestBed({
declarations: [DiagramTooltipComponent]
});
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [DiagramTooltipComponent]
});
fixture = TestBed.createComponent(DiagramTooltipComponent);
component = fixture.componentInstance;
data = {
@@ -123,16 +121,13 @@ describe('DiagramTooltipComponent', () => {
});
describe('Tooltip functionality', () => {
let fixture: ComponentFixture<TestHostComponent>;
setupTestBed({
declarations: [DiagramTooltipComponent, TestHostComponent]
});
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [DiagramTooltipComponent, TestHostComponent]
});
fixture = TestBed.createComponent(TestHostComponent);
fixture.detectChanges();
});

View File

@@ -16,7 +16,7 @@
*/
import { TestBed } from '@angular/core/testing';
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
import { AppConfigService } from '@alfresco/adf-core';
import { DiagramsService } from './diagrams.service';
import { InsightsTestingModule } from '../../testing/insights.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -24,17 +24,15 @@ import { TranslateModule } from '@ngx-translate/core';
declare let jasmine: any;
describe('DiagramsService', () => {
let service: DiagramsService;
setupTestBed({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
TranslateModule.forRoot(),
InsightsTestingModule
]
});
const appConfig: AppConfigService = TestBed.inject(AppConfigService);
appConfig.config.ecmHost = 'http://localhost:9876/ecm';