diff --git a/package-lock.json b/package-lock.json
index 0459c3704..f0973f96c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,12 +5,12 @@
"requires": true,
"dependencies": {
"@alfresco/adf-cli": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/@alfresco/adf-cli/-/adf-cli-4.1.0.tgz",
- "integrity": "sha512-G5XvgWukvVmoLCm5YO6A0FCJ7hHfCKwhX2urqO1M9Dmh13JgfYsJFl5s06TetdWmZMDCdU85nuVJaPKrOl9cXQ==",
+ "version": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "resolved": "https://registry.npmjs.org/@alfresco/adf-cli/-/adf-cli-4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189.tgz",
+ "integrity": "sha512-bXdeT/63rRMqX5T2qh+efJwCcNuO88jGnEVsTX7BRe8yLR5/NQo75tFltwwYyCDikm+llYoOnCPGVMPpj18S3w==",
"dev": true,
"requires": {
- "@alfresco/js-api": "4.1.0",
+ "@alfresco/js-api": "4.2.0-6ac370e9b9c807196a9ab3bc892d0a4956d1a14f",
"commander": "^4.0.0",
"ejs": "^2.6.1",
"license-checker": "^25.0.1",
@@ -20,17 +20,6 @@
"spdx-license-list": "^5.0.0"
},
"dependencies": {
- "@alfresco/js-api": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-4.1.0.tgz",
- "integrity": "sha512-9eWihZ3lNtI08cffrnTqB9G8j9syDbLegyTescj8J1vqcxaXF7pvFCfP1zcNRIzfEErx8ncqjFf+IMbh8lvb7A==",
- "dev": true,
- "requires": {
- "event-emitter": "^0.3.5",
- "minimatch": "3.0.4",
- "superagent": "^6.0.0"
- }
- },
"commander": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz",
@@ -40,42 +29,42 @@
}
},
"@alfresco/adf-content-services": {
- "version": "4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6",
- "resolved": "https://registry.npmjs.org/@alfresco/adf-content-services/-/adf-content-services-4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6.tgz",
- "integrity": "sha512-GDM0NcbgnCyGsE9WHjBNhyCUAjvSHmYhJ3a1GPVEA0oXA99GG8tEr7CVkVrJyq+6g5lGzh/ihrj4DH52S/R0zQ==",
+ "version": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "resolved": "https://registry.npmjs.org/@alfresco/adf-content-services/-/adf-content-services-4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189.tgz",
+ "integrity": "sha512-NC5uB5yN5p3dji1O1y344kcZSQsrk6zUpjgNXlReoIiW1W7qUULjlwcZM9o5cUnJfPCiktPdc5mjYU7dVTaf3A==",
"requires": {
"tslib": "^2.0.0"
}
},
"@alfresco/adf-core": {
- "version": "4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6",
- "resolved": "https://registry.npmjs.org/@alfresco/adf-core/-/adf-core-4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6.tgz",
- "integrity": "sha512-mZSrREoc9jV8uBIJfZJX4V86qj5iA6pWmmj2wfrCdq1nfsPWbhiEcqiQN9OpfvwMm58bdrzXX/FIS+Fox1U4Jg==",
+ "version": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "resolved": "https://registry.npmjs.org/@alfresco/adf-core/-/adf-core-4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189.tgz",
+ "integrity": "sha512-+UJSnZblEBfzy10wNVhXnIegjlfZ3Wzs6AD7Dunl9rOA3nPq0FxbzB0SbzozJ6FGvgncLOffCg+UT1xF47nK4A==",
"requires": {
"tslib": "^2.0.0"
}
},
"@alfresco/adf-extensions": {
- "version": "4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6",
- "resolved": "https://registry.npmjs.org/@alfresco/adf-extensions/-/adf-extensions-4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6.tgz",
- "integrity": "sha512-fE2Gm+qj8R2nfIj3xTHXZdykHwAMOw0mUk64PNjGF067d2aYoJiLX8EMKy/LL7hfmmLYUdPjOiTa1YmL7P6t9g==",
+ "version": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "resolved": "https://registry.npmjs.org/@alfresco/adf-extensions/-/adf-extensions-4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189.tgz",
+ "integrity": "sha512-moVIH1sc+Ri1lzHfMG4pLzXRLQ1V4aBiPBKpLa9lht/EnQKBhwpyzrUyqzVo0EheoBqOG0KGH9c+6oQa0tCByg==",
"requires": {
"tslib": "^2.0.0"
}
},
"@alfresco/adf-testing": {
- "version": "4.2.0-6ca8f53bab727b80dfd6fe0d5645187cdcb6082e",
- "resolved": "https://registry.npmjs.org/@alfresco/adf-testing/-/adf-testing-4.2.0-6ca8f53bab727b80dfd6fe0d5645187cdcb6082e.tgz",
- "integrity": "sha512-DdElhTIV+q4VPaWNe9UWcTsJdcI9eJEiHNRq+9WcAQPfsU7r+sgAFK17AipOkMgt0XbqJR2CfGmPKX5E+e1/Hg==",
+ "version": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "resolved": "https://registry.npmjs.org/@alfresco/adf-testing/-/adf-testing-4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189.tgz",
+ "integrity": "sha512-RJB6mHo3Z6666OuCpCODlkzctmm1Sa9PSGdEhj7oYxYNw6oX0F7iNXithHJeXba8FVO4nb6+F9xn5fSlxjXhtw==",
"dev": true,
"requires": {
"tslib": "^2.0.0"
}
},
"@alfresco/js-api": {
- "version": "4.2.0-3a7bedfc17429a8d30ce676b0c582087d037edaa",
- "resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-4.2.0-3a7bedfc17429a8d30ce676b0c582087d037edaa.tgz",
- "integrity": "sha512-cGPksQX87nJdGdXSdCX6ZJvgPt7dXnTbwfJ6h0In/6jR8vc6LkTUl/HOIsYo9dTyHVef94JzWWKbtw5V6fOk/g==",
+ "version": "4.2.0-6ac370e9b9c807196a9ab3bc892d0a4956d1a14f",
+ "resolved": "https://registry.npmjs.org/@alfresco/js-api/-/js-api-4.2.0-6ac370e9b9c807196a9ab3bc892d0a4956d1a14f.tgz",
+ "integrity": "sha512-8pCxAvqPogJk2QKgQSqTJ4NwHShYObs27/WuP8spXhqfbhvKv2R0oo0DJyuiIscocr8zESfoUUiHadLgxe/K6g==",
"requires": {
"event-emitter": "^0.3.5",
"minimatch": "3.0.4",
diff --git a/package.json b/package.json
index bd4ea814a..f8c8b06c5 100644
--- a/package.json
+++ b/package.json
@@ -24,10 +24,10 @@
},
"private": true,
"dependencies": {
- "@alfresco/adf-content-services": "4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6",
- "@alfresco/adf-core": "4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6",
- "@alfresco/adf-extensions": "4.2.0-418cd0e2d38c1e10b372ec44ae85a80f292c23d6",
- "@alfresco/js-api": "4.2.0-3a7bedfc17429a8d30ce676b0c582087d037edaa",
+ "@alfresco/adf-content-services": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "@alfresco/adf-core": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "@alfresco/adf-extensions": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "@alfresco/js-api": "4.2.0-6ac370e9b9c807196a9ab3bc892d0a4956d1a14f",
"@angular/animations": "10.0.4",
"@angular/cdk": "^10.0.2",
"@angular/common": "10.0.4",
@@ -56,8 +56,8 @@
"zone.js": "~0.10.2"
},
"devDependencies": {
- "@alfresco/adf-cli": "4.1.0",
- "@alfresco/adf-testing": "4.2.0-6ca8f53bab727b80dfd6fe0d5645187cdcb6082e",
+ "@alfresco/adf-cli": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
+ "@alfresco/adf-testing": "4.2.0-751ca039752178f1c9f59f28d2d21c247dbe5189",
"@angular-custom-builders/lite-serve": "^0.2.2",
"@angular-devkit/build-angular": "~0.1001.4",
"@angular-devkit/build-ng-packagr": "~0.1001.3",
diff --git a/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts b/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts
index 3c8fff711..5f3b00cad 100644
--- a/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts
+++ b/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts
@@ -25,15 +25,7 @@
import { PaginationDirective } from './pagination.directive';
import { TestBed, ComponentFixture } from '@angular/core/testing';
-import {
- UserPreferencesService,
- AppConfigService,
- PaginationComponent,
- PaginationModel,
- AlfrescoApiService,
- AlfrescoApiServiceMock,
- CoreTestingModule
-} from '@alfresco/adf-core';
+import { UserPreferencesService, AppConfigService, PaginationComponent, PaginationModel, CoreTestingModule } from '@alfresco/adf-core';
import { LibTestingModule } from '../testing/lib-testing-module';
import { SharedDirectivesModule } from './shared.directives.module';
import { TranslateModule } from '@ngx-translate/core';
@@ -47,8 +39,7 @@ describe('PaginationDirective', () => {
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [TranslateModule.forRoot(), LibTestingModule, SharedDirectivesModule, CoreTestingModule],
- providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
+ imports: [TranslateModule.forRoot(), LibTestingModule, SharedDirectivesModule, CoreTestingModule]
});
preferences = TestBed.inject(UserPreferencesService);
diff --git a/projects/aca-shared/src/lib/testing/lib-testing-module.ts b/projects/aca-shared/src/lib/testing/lib-testing-module.ts
index ac92714d2..65c762b9d 100644
--- a/projects/aca-shared/src/lib/testing/lib-testing-module.ts
+++ b/projects/aca-shared/src/lib/testing/lib-testing-module.ts
@@ -94,8 +94,7 @@ export const initialState = {
providers: [
provideMockStore({ initialState }),
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
- { provide: TranslationService, useClass: TranslationMock },
- AlfrescoApiService
+ { provide: TranslationService, useClass: TranslationMock }
]
})
export class LibTestingModule {}
diff --git a/src/app/components/common/location-link/location-link.component.spec.ts b/src/app/components/common/location-link/location-link.component.spec.ts
deleted file mode 100644
index 033da33c1..000000000
--- a/src/app/components/common/location-link/location-link.component.spec.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-/*!
- * @license
- * Alfresco Example Content Application
- *
- * Copyright (C) 2005 - 2020 Alfresco Software Limited
- *
- * This file is part of the Alfresco Example Content Application.
- * If the software was purchased under a paid Alfresco license, the terms of
- * the paid license agreement will prevail. Otherwise, the software is
- * provided under the following open source license terms:
- *
- * The Alfresco Example Content Application is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The Alfresco Example Content Application is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-
-import { LocationLinkComponent } from './location-link.component';
-
-describe('LocationLinkComponent', () => {
- it('should be defined', () => {
- expect(LocationLinkComponent).toBeDefined();
- });
-});
diff --git a/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts b/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts
index 56bc5d307..64fa3304b 100644
--- a/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts
+++ b/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts
@@ -26,7 +26,7 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router } from '@angular/router';
-import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe, UserPreferencesService } from '@alfresco/adf-core';
+import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigModule, UserPreferencesService } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { FavoriteLibrariesComponent } from './favorite-libraries.component';
import { AppTestingModule } from '../../testing/app-testing.module';
@@ -59,9 +59,8 @@ describe('FavoriteLibrariesComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [AppTestingModule, EffectsModule.forRoot([RouterEffects, LibraryEffects])],
- declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, FavoriteLibrariesComponent, AppConfigPipe],
- providers: [ContentManagementService, UserPreferencesService],
+ imports: [AppTestingModule, EffectsModule.forRoot([RouterEffects, LibraryEffects]), AppConfigModule],
+ declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, FavoriteLibrariesComponent],
schemas: [NO_ERRORS_SCHEMA]
});
diff --git a/src/app/components/favorites/favorites.component.spec.ts b/src/app/components/favorites/favorites.component.spec.ts
index b7e54031d..4018dcf88 100644
--- a/src/app/components/favorites/favorites.component.spec.ts
+++ b/src/app/components/favorites/favorites.component.spec.ts
@@ -26,8 +26,8 @@
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router } from '@angular/router';
import { TestBed, ComponentFixture } from '@angular/core/testing';
-import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core';
-import { DocumentListComponent } from '@alfresco/adf-content-services';
+import { NodeFavoriteDirective, DataTableComponent, AppConfigModule } from '@alfresco/adf-core';
+import { CustomResourcesService, DocumentListComponent } from '@alfresco/adf-content-services';
import { of } from 'rxjs';
import { FavoritesComponent } from './favorites.component';
import { AppTestingModule } from '../../testing/app-testing.module';
@@ -36,18 +36,27 @@ import { ContentApiService } from '@alfresco/aca-shared';
describe('FavoritesComponent', () => {
let fixture: ComponentFixture;
let component: FavoritesComponent;
- let alfrescoApi: AlfrescoApiService;
let contentApi: ContentApiService;
let router: Router;
- const mockRouter = {
- url: 'favorites',
- navigate: () => {}
- };
- let page;
let node;
beforeEach(() => {
- page = {
+ TestBed.configureTestingModule({
+ imports: [AppTestingModule, AppConfigModule],
+ declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, FavoritesComponent],
+ providers: [
+ {
+ provide: Router,
+ useValue: {
+ url: 'favorites',
+ navigate: () => {}
+ }
+ }
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ });
+
+ const page: any = {
list: {
entries: [{ entry: { id: 1, target: { file: {} } } }, { entry: { id: 2, target: { folder: {} } } }],
pagination: { data: 'data' }
@@ -62,27 +71,12 @@ describe('FavoritesComponent', () => {
elements: []
}
};
- });
-
- beforeEach(() => {
- TestBed.configureTestingModule({
- imports: [AppTestingModule],
- declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, FavoritesComponent, AppConfigPipe],
- providers: [
- {
- provide: Router,
- useValue: mockRouter
- }
- ],
- schemas: [NO_ERRORS_SCHEMA]
- });
fixture = TestBed.createComponent(FavoritesComponent);
component = fixture.componentInstance;
- alfrescoApi = TestBed.inject(AlfrescoApiService);
- alfrescoApi.reset();
- spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(page));
+ const customResourcesService = TestBed.inject(CustomResourcesService);
+ spyOn(customResourcesService, 'loadFavorites').and.returnValue(of(page));
contentApi = TestBed.inject(ContentApiService);
router = TestBed.inject(Router);
@@ -91,7 +85,7 @@ describe('FavoritesComponent', () => {
describe('Node navigation', () => {
beforeEach(() => {
spyOn(contentApi, 'getNode').and.returnValue(of({ entry: node }));
- spyOn(router, 'navigate');
+ spyOn(router, 'navigate').and.stub();
fixture.detectChanges();
});
@@ -136,7 +130,7 @@ describe('FavoritesComponent', () => {
component.onNodeDoubleClick(nodeEntity);
expect(component.showPreview).toHaveBeenCalledWith(nodeEntity, {
- location: mockRouter.url
+ location: 'favorites'
});
});
});
diff --git a/src/app/components/files/files.component.spec.ts b/src/app/components/files/files.component.spec.ts
index 28401effe..806f15000 100644
--- a/src/app/components/files/files.component.spec.ts
+++ b/src/app/components/files/files.component.spec.ts
@@ -26,16 +26,7 @@
import { TestBed, fakeAsync, tick, ComponentFixture } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
-import {
- NodeFavoriteDirective,
- DataTableComponent,
- UploadService,
- AppConfigPipe,
- AlfrescoApiService,
- AlfrescoApiServiceMock,
- DataTableModule,
- PaginationModule
-} from '@alfresco/adf-core';
+import { NodeFavoriteDirective, DataTableComponent, UploadService, AppConfigModule, DataTableModule, PaginationModule } from '@alfresco/adf-core';
import { DocumentListComponent, FilterSearch } from '@alfresco/adf-content-services';
import { NodeActionsService } from '../../services/node-actions.service';
import { FilesComponent } from './files.component';
@@ -70,10 +61,9 @@ describe('FilesComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [AppTestingModule, DataTableModule, PaginationModule, SharedDirectivesModule, DirectivesModule],
- declarations: [FilesComponent, DataTableComponent, NodeFavoriteDirective, DocumentListComponent, AppConfigPipe],
+ imports: [AppTestingModule, DataTableModule, PaginationModule, SharedDirectivesModule, DirectivesModule, AppConfigModule],
+ declarations: [FilesComponent, DataTableComponent, NodeFavoriteDirective, DocumentListComponent],
providers: [
- { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: Router,
useValue: router
diff --git a/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts b/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts
index 2abf4c169..b239d7c00 100644
--- a/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts
+++ b/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts
@@ -26,31 +26,28 @@
import { CommentsTabComponent } from './comments-tab.component';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AppTestingModule } from '../../../testing/app-testing.module';
-import { NO_ERRORS_SCHEMA } from '@angular/core';
import { NodePermissionService } from '@alfresco/aca-shared';
import { Node } from '@alfresco/js-api';
describe('CommentsTabComponent', () => {
let component: CommentsTabComponent;
let fixture: ComponentFixture;
- const permissionsMock = {
- check: jasmine.createSpy('check')
- };
- let checked;
+ let nodePermissionService: NodePermissionService;
+ let checked: string[];
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule],
- declarations: [CommentsTabComponent],
- providers: [{ provide: NodePermissionService, useValue: permissionsMock }],
- schemas: [NO_ERRORS_SCHEMA]
+ declarations: [CommentsTabComponent]
});
+ nodePermissionService = TestBed.inject(NodePermissionService);
+
fixture = TestBed.createComponent(CommentsTabComponent);
component = fixture.componentInstance;
checked = null;
- permissionsMock.check.and.callFake((_source, permissions) => {
+ spyOn(nodePermissionService, 'check').and.callFake((_source, permissions) => {
checked = permissions;
return true;
});
diff --git a/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts b/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts
index a464e1283..2d6a4f26b 100644
--- a/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts
+++ b/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts
@@ -29,34 +29,34 @@ import { UpdateLibraryAction } from '@alfresco/aca-shared/store';
import { AppTestingModule } from '../../../testing/app-testing.module';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Site, SitePaging } from '@alfresco/js-api';
-import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core';
+import { AlfrescoApiService } from '@alfresco/adf-core';
describe('LibraryMetadataFormComponent', () => {
let fixture: ComponentFixture;
let component: LibraryMetadataFormComponent;
let alfrescoApiService: AlfrescoApiService;
- const storeMock = {
- dispatch: jasmine.createSpy('dispatch')
- };
+ let store: Store;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule],
declarations: [LibraryMetadataFormComponent],
providers: [
- { provide: Store, useValue: storeMock },
- { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
+ {
+ provide: Store,
+ useValue: {
+ dispatch: jasmine.createSpy('dispatch')
+ }
+ }
],
schemas: [NO_ERRORS_SCHEMA]
});
+ store = TestBed.inject(Store);
+ alfrescoApiService = TestBed.inject(AlfrescoApiService);
+
fixture = TestBed.createComponent(LibraryMetadataFormComponent);
component = fixture.componentInstance;
- alfrescoApiService = TestBed.inject(AlfrescoApiService);
- });
-
- afterEach(() => {
- storeMock.dispatch.calls.reset();
});
it('should initialize form with node data', () => {
@@ -130,7 +130,7 @@ describe('LibraryMetadataFormComponent', () => {
component.update();
- expect(storeMock.dispatch).toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
+ expect(store.dispatch).toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
});
it('should not update library node if it has no permission', () => {
@@ -151,7 +151,7 @@ describe('LibraryMetadataFormComponent', () => {
component.update();
- expect(storeMock.dispatch).not.toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
+ expect(store.dispatch).not.toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
});
it('should not update library node if form is invalid', () => {
@@ -174,7 +174,7 @@ describe('LibraryMetadataFormComponent', () => {
component.update();
- expect(storeMock.dispatch).not.toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
+ expect(store.dispatch).not.toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel));
});
it('should toggle edit mode', () => {
diff --git a/src/app/components/libraries/libraries.component.spec.ts b/src/app/components/libraries/libraries.component.spec.ts
index 523c8a666..5177fea66 100644
--- a/src/app/components/libraries/libraries.component.spec.ts
+++ b/src/app/components/libraries/libraries.component.spec.ts
@@ -26,7 +26,7 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router } from '@angular/router';
-import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core';
+import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigModule } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { LibrariesComponent } from './libraries.component';
import { AppTestingModule } from '../../testing/app-testing.module';
@@ -51,8 +51,8 @@ describe('LibrariesComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [AppTestingModule, EffectsModule.forRoot([LibraryEffects])],
- declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, LibrariesComponent, AppConfigPipe],
+ imports: [AppTestingModule, EffectsModule.forRoot([LibraryEffects]), AppConfigModule],
+ declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, LibrariesComponent],
schemas: [NO_ERRORS_SCHEMA]
});
diff --git a/src/app/components/preview/preview.component.spec.ts b/src/app/components/preview/preview.component.spec.ts
index cd9efbe2f..3f14d29e6 100644
--- a/src/app/components/preview/preview.component.spec.ts
+++ b/src/app/components/preview/preview.component.spec.ts
@@ -23,10 +23,9 @@
* along with Alfresco. If not, see .
*/
-import { NO_ERRORS_SCHEMA } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { TestBed, ComponentFixture, async, fakeAsync, tick } from '@angular/core/testing';
-import { UserPreferencesService, AppConfigPipe, NodeFavoriteDirective, UploadService, AlfrescoApiService } from '@alfresco/adf-core';
+import { UserPreferencesService, UploadService, AlfrescoApiService } from '@alfresco/adf-core';
import { ClosePreviewAction } from '@alfresco/aca-shared/store';
import { PreviewComponent } from './preview.component';
import { of, throwError } from 'rxjs';
@@ -37,6 +36,7 @@ import { ContentApiService } from '@alfresco/aca-shared';
import { ContentManagementService } from '../../services/content-management.service';
import { Store } from '@ngrx/store';
import { Node, NodePaging, FavoritePaging, SharedLinkPaging, PersonEntry, ResultSetPaging } from '@alfresco/js-api';
+import { PreviewModule } from './preview.module';
describe('PreviewComponent', () => {
let fixture: ComponentFixture;
@@ -52,10 +52,7 @@ describe('PreviewComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [AppTestingModule, EffectsModule.forRoot([NodeEffects])],
- providers: [AlfrescoApiService, ContentManagementService],
- declarations: [AppConfigPipe, PreviewComponent, NodeFavoriteDirective],
- schemas: [NO_ERRORS_SCHEMA]
+ imports: [EffectsModule.forRoot([NodeEffects]), PreviewModule, AppTestingModule]
});
fixture = TestBed.createComponent(PreviewComponent);
diff --git a/src/app/components/recent-files/recent-files.component.spec.ts b/src/app/components/recent-files/recent-files.component.spec.ts
index 1b4ba5ddc..67c33961d 100644
--- a/src/app/components/recent-files/recent-files.component.spec.ts
+++ b/src/app/components/recent-files/recent-files.component.spec.ts
@@ -25,39 +25,27 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
-import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core';
-import { DocumentListComponent } from '@alfresco/adf-content-services';
+import { NodeFavoriteDirective, DataTableComponent, AppConfigModule } from '@alfresco/adf-core';
+import { CustomResourcesService, DocumentListComponent } from '@alfresco/adf-content-services';
import { RecentFilesComponent } from './recent-files.component';
import { AppTestingModule } from '../../testing/app-testing.module';
import { Router } from '@angular/router';
-import { PersonEntry } from '@alfresco/js-api';
+import { PersonEntry, ResultSetPaging } from '@alfresco/js-api';
describe('RecentFilesComponent', () => {
let fixture: ComponentFixture;
let component: RecentFilesComponent;
- let alfrescoApi: AlfrescoApiService;
- let page;
- const mockRouter = {
- url: 'recent-files'
- };
-
- beforeEach(() => {
- page = {
- list: {
- entries: [{ entry: { id: 1 } }, { entry: { id: 2 } }],
- pagination: { data: 'data' }
- }
- };
- });
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [AppTestingModule],
- declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, RecentFilesComponent, AppConfigPipe],
+ imports: [AppTestingModule, AppConfigModule],
+ declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, RecentFilesComponent],
providers: [
{
provide: Router,
- useValue: mockRouter
+ useValue: {
+ url: 'recent-files'
+ }
}
],
schemas: [NO_ERRORS_SCHEMA]
@@ -66,16 +54,24 @@ describe('RecentFilesComponent', () => {
fixture = TestBed.createComponent(RecentFilesComponent);
component = fixture.componentInstance;
- alfrescoApi = TestBed.inject(AlfrescoApiService);
- alfrescoApi.reset();
-
- spyOn(alfrescoApi.peopleApi, 'getPerson').and.returnValue(
+ const customResourcesService = TestBed.inject(CustomResourcesService);
+ spyOn(customResourcesService.peopleApi, 'getPerson').and.returnValue(
Promise.resolve({
entry: { id: 'personId' }
} as PersonEntry)
);
- spyOn(alfrescoApi.searchApi, 'search').and.returnValue(Promise.resolve(page));
+ const page: ResultSetPaging = {
+ list: {
+ entries: [
+ { entry: { id: '1', name: 'node1', nodeType: 'cm:file', isFile: true, isFolder: false } },
+ { entry: { id: '2', name: 'node2', nodeType: 'cm:file', isFile: true, isFolder: false } }
+ ],
+ pagination: { count: 2, totalItems: 2 }
+ }
+ };
+
+ spyOn(customResourcesService.searchApi, 'search').and.returnValue(Promise.resolve(page));
});
it('should call showPreview method', () => {
@@ -85,7 +81,7 @@ describe('RecentFilesComponent', () => {
component.onNodeDoubleClick(node);
expect(component.showPreview).toHaveBeenCalledWith(node, {
- location: mockRouter.url
+ location: 'recent-files'
});
});
});
diff --git a/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts b/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts
index 17d38a0f9..f965c0219 100644
--- a/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts
+++ b/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts
@@ -25,7 +25,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AppTestingModule } from '../../../testing/app-testing.module';
-import { AppConfigPipe, DataTableComponent } from '@alfresco/adf-core';
+import { AppConfigModule, DataTableComponent } from '@alfresco/adf-core';
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { SearchLibrariesResultsComponent } from './search-libraries-results.component';
import { SearchLibrariesQueryBuilderService } from './search-libraries-query-builder.service';
@@ -39,8 +39,8 @@ describe('SearchLibrariesResultsComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [AppTestingModule],
- declarations: [DataTableComponent, DocumentListComponent, SearchLibrariesResultsComponent, AppConfigPipe],
+ imports: [AppTestingModule, AppConfigModule],
+ declarations: [DataTableComponent, DocumentListComponent, SearchLibrariesResultsComponent],
schemas: [NO_ERRORS_SCHEMA],
providers: [SearchLibrariesQueryBuilderService]
});
diff --git a/src/app/components/search/search-results/search-results.component.spec.ts b/src/app/components/search/search-results/search-results.component.spec.ts
index 8949042ba..e77bd93bc 100644
--- a/src/app/components/search/search-results/search-results.component.spec.ts
+++ b/src/app/components/search/search-results/search-results.component.spec.ts
@@ -27,7 +27,7 @@ import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testin
import { SearchResultsComponent } from './search-results.component';
import { AppTestingModule } from '../../../testing/app-testing.module';
import { AppSearchResultsModule } from '../search-results.module';
-import { CoreModule, AppConfigService, AlfrescoApiService, AlfrescoApiServiceMock, TranslationService } from '@alfresco/adf-core';
+import { CoreModule, AppConfigService, AlfrescoApiService, TranslationService } from '@alfresco/adf-core';
import { Store } from '@ngrx/store';
import { NavigateToFolder, SnackbarErrorAction } from '@alfresco/aca-shared/store';
import { Pagination, SearchRequest } from '@alfresco/js-api';
@@ -50,10 +50,6 @@ describe('SearchComponent', () => {
TestBed.configureTestingModule({
imports: [TranslateModule.forRoot(), CoreModule.forRoot(), AppTestingModule, AppSearchResultsModule],
providers: [
- {
- provide: AlfrescoApiService,
- useClass: AlfrescoApiServiceMock
- },
{
provide: ActivatedRoute,
useValue: {
diff --git a/src/app/components/shared-files/shared-files.component.spec.ts b/src/app/components/shared-files/shared-files.component.spec.ts
index 3ec5f4480..10b5eb0a8 100644
--- a/src/app/components/shared-files/shared-files.component.spec.ts
+++ b/src/app/components/shared-files/shared-files.component.spec.ts
@@ -25,7 +25,7 @@
import { TestBed, ComponentFixture } from '@angular/core/testing';
import { NO_ERRORS_SCHEMA } from '@angular/core';
-import { AlfrescoApiService, AlfrescoApiServiceMock, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core';
+import { NodeFavoriteDirective, DataTableComponent, AppConfigModule } from '@alfresco/adf-core';
import { CustomResourcesService, DocumentListComponent } from '@alfresco/adf-content-services';
import { SharedFilesComponent } from './shared-files.component';
import { AppTestingModule } from '../../testing/app-testing.module';
@@ -36,42 +36,31 @@ import { SharedLinkPaging } from '@alfresco/js-api';
describe('SharedFilesComponent', () => {
let fixture: ComponentFixture;
- let alfrescoApi: AlfrescoApiService;
let page: SharedLinkPaging;
- let customResourcesService: CustomResourcesService;
- const mockRouter = {
- url: 'shared-files'
- };
beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [AppTestingModule, AppConfigModule],
+ declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, SharedFilesComponent],
+ providers: [
+ {
+ provide: Router,
+ useValue: {
+ url: 'shared-files'
+ }
+ }
+ ],
+ schemas: [NO_ERRORS_SCHEMA]
+ });
+
page = {
list: {
entries: [{ entry: { id: '1' } }, { entry: { id: '2' } }],
pagination: { count: 2 }
}
};
- });
- beforeEach(() => {
- TestBed.configureTestingModule({
- imports: [AppTestingModule],
- declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, SharedFilesComponent, AppConfigPipe],
- providers: [
- { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
- {
- provide: Router,
- useValue: mockRouter
- }
- ],
- schemas: [NO_ERRORS_SCHEMA]
- });
-
- customResourcesService = TestBed.inject(CustomResourcesService);
-
- alfrescoApi = TestBed.inject(AlfrescoApiService);
- alfrescoApi.reset();
-
- spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(page));
+ const customResourcesService = TestBed.inject(CustomResourcesService);
spyOn(customResourcesService, 'loadSharedLinks').and.returnValue(of(page));
fixture = TestBed.createComponent(SharedFilesComponent);
diff --git a/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts b/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts
index 0b82dccc8..92867bae3 100644
--- a/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts
+++ b/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts
@@ -24,7 +24,7 @@
*/
import { TestBed, ComponentFixture } from '@angular/core/testing';
-import { CoreModule, AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core';
+import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
import { ToggleFavoriteLibraryComponent } from './toggle-favorite-library.component';
import { LibraryFavoriteDirective } from '../../../directives/library-favorite.directive';
import { NO_ERRORS_SCHEMA } from '@angular/core';
@@ -37,8 +37,9 @@ import { TranslateModule } from '@ngx-translate/core';
describe('ToggleFavoriteLibraryComponent', () => {
let fixture: ComponentFixture;
- let component;
- let contentManagementService;
+ let component: ToggleFavoriteLibraryComponent;
+ let contentManagementService: ContentManagementService;
+
const selection = { library: { entry: { id: 'libraryId' } } };
const mockRouter = {
url: ''
@@ -53,10 +54,6 @@ describe('ToggleFavoriteLibraryComponent', () => {
provide: Router,
useValue: mockRouter
},
- {
- provide: AlfrescoApiService,
- useClass: AlfrescoApiServiceMock
- },
{
provide: Store,
useValue: {
diff --git a/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts b/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts
index eaeec0b4e..df35d2e36 100644
--- a/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts
+++ b/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts
@@ -25,7 +25,7 @@
import { of } from 'rxjs';
import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core';
+import { AlfrescoApiService } from '@alfresco/adf-core';
import { LibraryMembershipDirective } from '../../../directives/library-membership.directive';
import { Store } from '@ngrx/store';
import { NO_ERRORS_SCHEMA } from '@angular/core';
@@ -39,13 +39,9 @@ describe('ToggleJoinLibraryComponent', () => {
let fixture: ComponentFixture;
let alfrescoApi: AlfrescoApiService;
let contentManagementService: ContentManagementService;
+ let store: Store;
let entry;
- const storeMock = {
- select: () => of({ library: { entry, isLibrary: true } }),
- dispatch: jasmine.createSpy('dispatch')
- };
-
beforeEach(() => {
entry = {
id: 'lib-id',
@@ -58,23 +54,29 @@ describe('ToggleJoinLibraryComponent', () => {
imports: [AppTestingModule],
declarations: [ToggleJoinLibraryButtonComponent, LibraryMembershipDirective],
providers: [
- { provide: Store, useValue: storeMock },
- { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
+ {
+ provide: Store,
+ useValue: {
+ select: () => of({ library: { entry, isLibrary: true } }),
+ dispatch: jasmine.createSpy('dispatch')
+ }
+ }
],
schemas: [NO_ERRORS_SCHEMA]
});
- fixture = TestBed.createComponent(ToggleJoinLibraryButtonComponent);
- component = fixture.componentInstance;
+ store = TestBed.inject(Store);
alfrescoApi = TestBed.inject(AlfrescoApiService);
contentManagementService = TestBed.inject(ContentManagementService);
spyOn(alfrescoApi.peopleApi, 'getSiteMembershipRequest').and.stub();
+
+ fixture = TestBed.createComponent(ToggleJoinLibraryButtonComponent);
+ component = fixture.componentInstance;
});
afterEach(() => {
fixture.destroy();
- storeMock.dispatch.calls.reset();
});
it('should get Store selection entry on initialization', (done) => {
@@ -88,21 +90,21 @@ describe('ToggleJoinLibraryComponent', () => {
const event = { error: {}, i18nKey: 'ERROR_i18nKey' };
component.onErrorEvent(event);
- expect(storeMock.dispatch).toHaveBeenCalledWith(new SnackbarErrorAction(event.i18nKey));
+ expect(store.dispatch).toHaveBeenCalledWith(new SnackbarErrorAction(event.i18nKey));
});
it('should dispatch `SnackbarInfoAction` action on onToggleEvent', () => {
const event = { shouldReload: true, i18nKey: 'SOME_i18nKey' };
component.onToggleEvent(event);
- expect(storeMock.dispatch).toHaveBeenCalledWith(new SnackbarInfoAction(event.i18nKey));
+ expect(store.dispatch).toHaveBeenCalledWith(new SnackbarInfoAction(event.i18nKey));
});
it('should dispatch `ReloadLibraryAction` action on onToggleEvent', () => {
const event = { shouldReload: true, i18nKey: 'SOME_i18nKey' };
component.onToggleEvent(event);
- expect(storeMock.dispatch).toHaveBeenCalledWith(new ReloadLibraryAction());
+ expect(store.dispatch).toHaveBeenCalledWith(new ReloadLibraryAction());
});
it('should call libraryJoined.next on contentManagementService onToggleEvent', (done) => {
diff --git a/src/app/components/trashcan/trashcan.component.spec.ts b/src/app/components/trashcan/trashcan.component.spec.ts
index 8dcb6b410..da14beb3b 100644
--- a/src/app/components/trashcan/trashcan.component.spec.ts
+++ b/src/app/components/trashcan/trashcan.component.spec.ts
@@ -24,7 +24,7 @@
*/
import { NO_ERRORS_SCHEMA } from '@angular/core';
import { TestBed, ComponentFixture } from '@angular/core/testing';
-import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core';
+import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigModule } from '@alfresco/adf-core';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { TrashcanComponent } from './trashcan.component';
import { AppTestingModule } from '../../testing/app-testing.module';
@@ -46,8 +46,8 @@ describe('TrashcanComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [AppTestingModule],
- declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, TrashcanComponent, AppConfigPipe],
+ imports: [AppTestingModule, AppConfigModule],
+ declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, TrashcanComponent],
schemas: [NO_ERRORS_SCHEMA]
});
diff --git a/src/app/dialogs/node-versions/node-versions.dialog.spec.ts b/src/app/dialogs/node-versions/node-versions.dialog.spec.ts
index e423af005..0e19a7f35 100644
--- a/src/app/dialogs/node-versions/node-versions.dialog.spec.ts
+++ b/src/app/dialogs/node-versions/node-versions.dialog.spec.ts
@@ -25,7 +25,7 @@
import { NodeVersionsDialogComponent } from './node-versions.dialog';
import { ComponentFixture, TestBed } from '@angular/core/testing';
-import { AlfrescoApiService, AlfrescoApiServiceMock, CoreModule, TranslationMock } from '@alfresco/adf-core';
+import { CoreModule } from '@alfresco/adf-core';
import { AppTestingModule } from '../../testing/app-testing.module';
import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog';
import { Store } from '@ngrx/store';
@@ -36,9 +36,9 @@ import {
VersionListComponent,
VersionUploadComponent
} from '@alfresco/adf-content-services';
-import { TranslateFakeLoader, TranslateLoader, TranslateModule } from '@ngx-translate/core';
import { AppStore, UnlockWriteAction, ViewNodeExtras, ViewNodeVersionAction } from '@alfresco/aca-shared/store';
import { RouterTestingModule } from '@angular/router/testing';
+import { TranslateModule } from '@ngx-translate/core';
describe('NodeVersionsDialogComponent', () => {
let fixture: ComponentFixture;
@@ -46,15 +46,7 @@ describe('NodeVersionsDialogComponent', () => {
let store: Store;
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [
- CoreModule.forRoot(),
- AppTestingModule,
- MatDialogModule,
- RouterTestingModule.withRoutes([]),
- TranslateModule.forRoot({
- loader: { provide: TranslateLoader, useClass: TranslateFakeLoader }
- })
- ],
+ imports: [CoreModule.forRoot(), TranslateModule.forRoot(), MatDialogModule, RouterTestingModule.withRoutes([]), AppTestingModule],
declarations: [
NodeVersionsDialogComponent,
VersionListComponent,
@@ -63,10 +55,6 @@ describe('NodeVersionsDialogComponent', () => {
VersionComparisonComponent
],
providers: [
- {
- provide: AlfrescoApiService,
- useClass: AlfrescoApiServiceMock
- },
{
provide: MatDialogRef,
useValue: {
@@ -74,12 +62,6 @@ describe('NodeVersionsDialogComponent', () => {
open: jasmine.createSpy('open')
}
},
- {
- provide: TranslationMock,
- useValue: {
- instant: jasmine.createSpy('instant')
- }
- },
{
provide: Store,
useValue: {
diff --git a/src/app/directives/library-favorite.directive.spec.ts b/src/app/directives/library-favorite.directive.spec.ts
index 75407f15e..19c632bb6 100644
--- a/src/app/directives/library-favorite.directive.spec.ts
+++ b/src/app/directives/library-favorite.directive.spec.ts
@@ -25,9 +25,10 @@
import { Component, ViewChild } from '@angular/core';
import { LibraryFavoriteDirective } from './library-favorite.directive';
-import { AlfrescoApiService, AlfrescoApiServiceMock, setupTestBed, CoreModule } from '@alfresco/adf-core';
+import { AlfrescoApiService, CoreModule } from '@alfresco/adf-core';
import { TestBed, async, ComponentFixture } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
+import { AppTestingModule } from '../testing/app-testing.module';
@Component({
selector: 'app-test-component',
@@ -46,18 +47,11 @@ describe('LibraryFavoriteDirective', () => {
let component: TestComponent;
let selection: { entry: { guid: string; id: string } };
- setupTestBed({
- imports: [TranslateModule.forRoot(), CoreModule.forRoot()],
- declarations: [TestComponent, LibraryFavoriteDirective],
- providers: [
- {
- provide: AlfrescoApiService,
- useClass: AlfrescoApiServiceMock
- }
- ]
- });
-
beforeEach(() => {
+ TestBed.configureTestingModule({
+ imports: [TranslateModule.forRoot(), CoreModule.forRoot(), AppTestingModule],
+ declarations: [TestComponent, LibraryFavoriteDirective]
+ });
fixture = TestBed.createComponent(TestComponent);
component = fixture.componentInstance;
api = TestBed.inject(AlfrescoApiService);
diff --git a/src/app/directives/library-membership.directive.spec.ts b/src/app/directives/library-membership.directive.spec.ts
index 3b15dbd09..9d48b7e4a 100644
--- a/src/app/directives/library-membership.directive.spec.ts
+++ b/src/app/directives/library-membership.directive.spec.ts
@@ -24,7 +24,7 @@
*/
import { fakeAsync, TestBed, tick } from '@angular/core/testing';
-import { AlfrescoApiService, AlfrescoApiServiceMock, AppConfigService, CoreModule, SitesService, StorageService } from '@alfresco/adf-core';
+import { AlfrescoApiService, CoreModule, SitesService } from '@alfresco/adf-core';
import { AppTestingModule } from '../testing/app-testing.module';
import { DirectivesModule } from './directives.module';
import { LibraryMembershipDirective } from './library-membership.directive';
@@ -35,32 +35,37 @@ import { TranslateModule } from '@ngx-translate/core';
describe('LibraryMembershipDirective', () => {
let alfrescoApiService: AlfrescoApiService;
let directive: LibraryMembershipDirective;
- let peopleApi;
- let sitesService;
- let addMembershipSpy;
- let getMembershipSpy;
- let deleteMembershipSpy;
+ let peopleApi: any;
+ let sitesService: SitesService;
+ let addMembershipSpy: jasmine.Spy;
+ let getMembershipSpy: jasmine.Spy;
+ let deleteMembershipSpy: jasmine.Spy;
let mockSupportedVersion = false;
- const testSiteEntry = {
- id: 'id-1',
- guid: 'site-1',
- title: 'aa t m',
- visibility: 'MODERATED'
- };
- const requestedMembershipResponse = {
- id: testSiteEntry.id,
- createdAt: '2018-11-14',
- site: testSiteEntry
- };
+ let testSiteEntry: any;
+ let requestedMembershipResponse: any;
beforeEach(() => {
TestBed.configureTestingModule({
- imports: [TranslateModule.forRoot(), AppTestingModule, DirectivesModule, CoreModule.forRoot()],
+ imports: [TranslateModule.forRoot(), DirectivesModule, CoreModule.forRoot(), AppTestingModule],
schemas: [NO_ERRORS_SCHEMA]
});
- alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
- sitesService = new SitesService(alfrescoApiService);
+
+ testSiteEntry = {
+ id: 'id-1',
+ guid: 'site-1',
+ title: 'aa t m',
+ visibility: 'MODERATED'
+ };
+
+ requestedMembershipResponse = {
+ id: testSiteEntry.id,
+ createdAt: '2018-11-14',
+ site: testSiteEntry
+ };
+
+ alfrescoApiService = TestBed.inject(AlfrescoApiService);
+ sitesService = TestBed.inject(SitesService);
peopleApi = alfrescoApiService.getInstance().core.peopleApi;
directive = new LibraryMembershipDirective(alfrescoApiService, sitesService, {
ecmProductInfo$: new Subject(),
@@ -161,7 +166,7 @@ describe('LibraryMembershipDirective', () => {
}));
it('should call API to add user to library if admin user', fakeAsync(() => {
- const createSiteMembershipSpy = spyOn(sitesService, 'createSiteMembership').and.returnValue(of({}));
+ const createSiteMembershipSpy = spyOn(sitesService, 'createSiteMembership').and.returnValue(of({} as any));
const selection = { entry: { id: 'no-membership-requested' } };
const selectionChange = new SimpleChange(null, selection, true);
directive.isAdmin = true;
diff --git a/src/app/directives/lock-node.directive.spec.ts b/src/app/directives/lock-node.directive.spec.ts
index fa96efaaa..197391b35 100644
--- a/src/app/directives/lock-node.directive.spec.ts
+++ b/src/app/directives/lock-node.directive.spec.ts
@@ -25,9 +25,10 @@
import { Component, ViewChild } from '@angular/core';
import { LockNodeDirective } from './lock-node.directive';
-import { AlfrescoApiService, AlfrescoApiServiceMock, setupTestBed, CoreModule } from '@alfresco/adf-core';
+import { AlfrescoApiService, setupTestBed, CoreModule } from '@alfresco/adf-core';
import { TestBed, fakeAsync, tick } from '@angular/core/testing';
import { TranslateModule } from '@ngx-translate/core';
+import { AppTestingModule } from '../testing/app-testing.module';
@Component({
selector: 'app-test-component',
@@ -46,14 +47,8 @@ describe('LockNodeDirective', () => {
let component;
setupTestBed({
- imports: [TranslateModule.forRoot(), CoreModule.forRoot()],
- declarations: [TestComponent, LockNodeDirective],
- providers: [
- {
- provide: AlfrescoApiService,
- useClass: AlfrescoApiServiceMock
- }
- ]
+ imports: [TranslateModule.forRoot(), CoreModule.forRoot(), AppTestingModule],
+ declarations: [TestComponent, LockNodeDirective]
});
beforeEach(() => {
diff --git a/src/app/services/node-template.service.spec.ts b/src/app/services/node-template.service.spec.ts
index 593ddb4ab..5d987d275 100644
--- a/src/app/services/node-template.service.spec.ts
+++ b/src/app/services/node-template.service.spec.ts
@@ -30,7 +30,7 @@ import { TemplateEffects } from '../store/effects/template.effects';
import { AppTestingModule } from '../testing/app-testing.module';
import { Store } from '@ngrx/store';
import { MatDialog } from '@angular/material/dialog';
-import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core';
+import { AlfrescoApiService } from '@alfresco/adf-core';
import { NodeTemplateService } from './node-template.service';
import { ResultSetPaging } from '@alfresco/js-api';
@@ -51,7 +51,7 @@ describe('NodeTemplateService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [AppTestingModule, EffectsModule.forRoot([TemplateEffects])],
- providers: [NodeTemplateService, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }]
+ providers: [NodeTemplateService]
});
store = TestBed.inject(Store);
diff --git a/src/app/store/effects/template.effects.spec.ts b/src/app/store/effects/template.effects.spec.ts
index 70c1d68fe..d10a0c991 100644
--- a/src/app/store/effects/template.effects.spec.ts
+++ b/src/app/store/effects/template.effects.spec.ts
@@ -31,7 +31,7 @@ import { Store } from '@ngrx/store';
import { CreateFromTemplate, CreateFromTemplateSuccess, FileFromTemplate, FolderFromTemplate, SnackbarErrorAction } from '@alfresco/aca-shared/store';
import { NodeTemplateService } from '../../services/node-template.service';
import { of, Subject } from 'rxjs';
-import { AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core';
+import { AlfrescoApiService } from '@alfresco/adf-core';
import { ContentManagementService } from '../../services/content-management.service';
import { Node, NodeEntry } from '@alfresco/js-api';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
@@ -77,7 +77,6 @@ describe('TemplateEffects', () => {
imports: [AppTestingModule, EffectsModule.forRoot([TemplateEffects])],
providers: [
NodeTemplateService,
- { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{
provide: MatDialog,
useValue: {
diff --git a/src/app/testing/app-testing.module.ts b/src/app/testing/app-testing.module.ts
index 0fef4b688..5e83bd344 100644
--- a/src/app/testing/app-testing.module.ts
+++ b/src/app/testing/app-testing.module.ts
@@ -30,27 +30,17 @@ import {
TranslationService,
TranslationMock,
AuthenticationService,
- UserPreferencesService,
DiscoveryApiService,
EcmProductVersionModel,
- AppConfigService,
- StorageService,
AlfrescoApiService,
- LogService,
- NotificationService,
- NodesApiService,
- ContentService,
- ThumbnailService,
- UploadService,
- AlfrescoApiMock,
- PipeModule
+ PipeModule,
+ AlfrescoApiServiceMock
} from '@alfresco/adf-core';
import { HttpClientModule } from '@angular/common/http';
import { StoreModule } from '@ngrx/store';
import { appReducer } from '../store/reducers/app.reducer';
import { RouterTestingModule } from '@angular/router/testing';
import { EffectsModule } from '@ngrx/effects';
-import { CustomResourcesService, DocumentListService } from '@alfresco/adf-content-services';
import { MaterialModule } from '../material.module';
import { INITIAL_STATE } from '../store/initial-state';
import { TranslatePipeMock } from './translate-pipe.directive';
@@ -79,7 +69,7 @@ import { BehaviorSubject, Observable, of } from 'rxjs';
declarations: [TranslatePipeMock],
exports: [TranslatePipeMock, RouterTestingModule, MaterialModule, PipeModule],
providers: [
- { provide: AlfrescoApiService, useClass: AlfrescoApiMock },
+ { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
{ provide: TranslationService, useClass: TranslationMock },
{ provide: TranslateService, useClass: TranslateServiceMock },
{ provide: TranslatePipe, useClass: TranslatePipeMock },
@@ -109,19 +99,7 @@ import { BehaviorSubject, Observable, of } from 'rxjs';
return false;
}
}
- },
- UserPreferencesService,
- AppConfigService,
- StorageService,
- AlfrescoApiService,
- LogService,
- NotificationService,
- NodesApiService,
- ContentService,
- ThumbnailService,
- UploadService,
- CustomResourcesService,
- DocumentListService
+ }
]
})
export class AppTestingModule {}