mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-08-07 17:48:54 +00:00
[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:
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import { ChangeDetectorRef, Component, ElementRef, SimpleChange } from '@angular/core';
|
||||
import { CoreTestingModule, setupTestBed } from '@alfresco/adf-core';
|
||||
import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { ContentService } from '../common/services/content.service';
|
||||
import { CheckAllowableOperationDirective } from './check-allowable-operation.directive';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
@@ -32,17 +32,15 @@ class TestComponent implements NodeAllowableOperationSubject {
|
||||
}
|
||||
|
||||
describe('CheckAllowableOperationDirective', () => {
|
||||
|
||||
let changeDetectorMock: ChangeDetectorRef;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
changeDetectorMock = { detectChanges: () => {} } as ChangeDetectorRef;
|
||||
});
|
||||
|
||||
|
@@ -19,7 +19,7 @@ import { Component, DebugElement, ViewChild } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NodeDeleteDirective } from './node-delete.directive';
|
||||
import { setupTestBed, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ContentDirectiveModule } from './content-directive.module';
|
||||
|
||||
@@ -88,20 +88,19 @@ describe('NodeDeleteDirective', () => {
|
||||
let deleteNodePermanentSpy: any;
|
||||
let purgeDeletedNodePermanentSpy: any;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule,
|
||||
ContentDirectiveModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent,
|
||||
TestWithPermissionsComponent,
|
||||
TestDeletePermanentComponent
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule,
|
||||
ContentDirectiveModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent,
|
||||
TestWithPermissionsComponent,
|
||||
TestDeletePermanentComponent
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
fixtureWithPermissions = TestBed.createComponent(TestWithPermissionsComponent);
|
||||
fixtureWithPermanentComponent = TestBed.createComponent(TestDeletePermanentComponent);
|
||||
|
@@ -19,7 +19,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { Component, DebugElement, ViewChild } from '@angular/core';
|
||||
import { setupTestBed, AlfrescoApiService, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { NodeDownloadDirective } from './node-download.directive';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { ContentDirectiveModule } from '@alfresco/adf-content-services';
|
||||
@@ -51,18 +51,17 @@ describe('NodeDownloadDirective', () => {
|
||||
reply: jasmine.createSpy('reply')
|
||||
};
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
ContentDirectiveModule,
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
ContentDirectiveModule,
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.debugElement.query(By.directive(NodeDownloadDirective));
|
||||
|
@@ -19,21 +19,20 @@ import { SimpleChange } from '@angular/core';
|
||||
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
|
||||
import { NodeFavoriteDirective } from './node-favorite.directive';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { AlfrescoApiService, CoreTestingModule, setupTestBed } from '@alfresco/adf-core';
|
||||
import { AlfrescoApiService, CoreTestingModule } from '@alfresco/adf-core';
|
||||
|
||||
describe('NodeFavoriteDirective', () => {
|
||||
|
||||
let directive: NodeFavoriteDirective;
|
||||
let alfrescoApiService: AlfrescoApiService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule
|
||||
]
|
||||
});
|
||||
alfrescoApiService = TestBed.inject(AlfrescoApiService);
|
||||
directive = new NodeFavoriteDirective( alfrescoApiService);
|
||||
});
|
||||
|
@@ -18,11 +18,9 @@
|
||||
import { TestBed, ComponentFixture, fakeAsync } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Component, DebugElement } from '@angular/core';
|
||||
|
||||
import { NodeLockDirective } from './node-lock.directive';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { ContentNodeDialogService } from '../content-node-selector/content-node-dialog.service';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
@@ -45,17 +43,16 @@ describe('NodeLock Directive', () => {
|
||||
let element: DebugElement;
|
||||
let contentNodeDialogService: ContentNodeDialogService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
ContentTestingModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.debugElement.query(By.directive(NodeLockDirective));
|
||||
|
@@ -20,7 +20,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { NodeRestoreDirective } from './node-restore.directive';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { TranslationService, setupTestBed, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { TranslationService, CoreTestingModule } from '@alfresco/adf-core';
|
||||
import { ContentDirectiveModule } from './content-directive.module';
|
||||
|
||||
@Component({
|
||||
@@ -44,18 +44,17 @@ describe('NodeRestoreDirective', () => {
|
||||
let restoreNodeSpy: any;
|
||||
let translationService: TranslationService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule,
|
||||
ContentDirectiveModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent
|
||||
]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
CoreTestingModule,
|
||||
ContentDirectiveModule
|
||||
],
|
||||
declarations: [
|
||||
TestComponent
|
||||
]
|
||||
});
|
||||
fixture = TestBed.createComponent(TestComponent);
|
||||
component = fixture.componentInstance;
|
||||
element = fixture.debugElement.query(By.directive(NodeRestoreDirective));
|
||||
|
Reference in New Issue
Block a user