diff --git a/src/app/components/favorites/favorites.component.spec.ts b/src/app/components/favorites/favorites.component.spec.ts
index 0e1cfa73e..9c695851e 100644
--- a/src/app/components/favorites/favorites.component.spec.ts
+++ b/src/app/components/favorites/favorites.component.spec.ts
@@ -23,14 +23,26 @@
* along with Alfresco. If not, see .
*/
-import { Router } from '@angular/router';
-import { RouterTestingModule } from '@angular/router/testing';
-import { TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
-import { CoreModule, NodesApiService, AlfrescoApiService, ContentService } from '@alfresco/adf-core';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { Router, ActivatedRoute } from '@angular/router';
+import { RouterTestingModule } from '@angular/router/testing';
+import { HttpClientModule } from '@angular/common/http';
+import { TestBed, async } from '@angular/core/testing';
+import {
+ NotificationService, TranslationService, TranslationMock,
+ NodesApiService, AlfrescoApiService, ContentService,
+ UserPreferencesService, LogService, AppConfigService,
+ StorageService, CookieService, ThumbnailService,
+ AuthenticationService, TimeAgoPipe, NodeNameTooltipPipe,
+ NodeFavoriteDirective, DataTableComponent
+} from '@alfresco/adf-core';
+import { DocumentListComponent } from '@alfresco/adf-content-services';
-import { CommonModule } from '../../common/common.module';
-import { LocationLinkComponent } from '../location-link/location-link.component';
+import { TranslateModule } from '@ngx-translate/core';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { MatMenuModule, MatSnackBarModule, MatIconModule } from '@angular/material';
+import { DocumentListService } from '@alfresco/adf-content-services';
import { ContentManagementService } from '../../common/services/content-management.service';
import { FavoritesComponent } from './favorites.component';
@@ -42,6 +54,7 @@ describe('Favorites Routed Component', () => {
let alfrescoApi: AlfrescoApiService;
let alfrescoContentService: ContentService;
let contentService: ContentManagementService;
+ let preferenceService: UserPreferencesService;
let router: Router;
let page;
let node;
@@ -75,14 +88,39 @@ describe('Favorites Routed Component', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
- CoreModule,
- CommonModule,
- RouterTestingModule
+ MatMenuModule,
+ NoopAnimationsModule,
+ HttpClientModule,
+ TranslateModule.forRoot(),
+ RouterTestingModule,
+ MatSnackBarModule, MatIconModule
],
declarations: [
- LocationLinkComponent,
+ DataTableComponent,
+ TimeAgoPipe,
+ NodeNameTooltipPipe,
+ NodeFavoriteDirective,
+ DocumentListComponent,
FavoritesComponent
- ]
+ ],
+ providers: [
+ { provide: ActivatedRoute, useValue: {
+ snapshot: { data: { preferencePrefix: 'prefix' } }
+ } } ,
+ { provide: TranslationService, useClass: TranslationMock },
+ AuthenticationService,
+ UserPreferencesService,
+ AppConfigService, StorageService, CookieService,
+ AlfrescoApiService,
+ LogService,
+ NotificationService,
+ ContentManagementService,
+ ContentService,
+ NodesApiService,
+ DocumentListService,
+ ThumbnailService
+ ],
+ schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents().then(() => {
fixture = TestBed.createComponent(FavoritesComponent);
@@ -92,6 +130,7 @@ describe('Favorites Routed Component', () => {
alfrescoApi = TestBed.get(AlfrescoApiService);
alfrescoContentService = TestBed.get(ContentService);
contentService = TestBed.get(ContentManagementService);
+ preferenceService = TestBed.get(UserPreferencesService);
router = TestBed.get(Router);
});
}));
@@ -101,23 +140,34 @@ describe('Favorites Routed Component', () => {
});
describe('Events', () => {
- it('should refresh on editing folder event', () => {
+ beforeEach(() => {
spyOn(component, 'refresh');
fixture.detectChanges();
+ });
+ it('should refresh on editing folder event', () => {
alfrescoContentService.folderEdit.next(null);
expect(component.refresh).toHaveBeenCalled();
});
it('should refresh on move node event', () => {
- spyOn(component, 'refresh');
- fixture.detectChanges();
-
contentService.nodeMoved.next(null);
expect(component.refresh).toHaveBeenCalled();
});
+
+ it('should refresh on node deleted event', () => {
+ contentService.nodeDeleted.next(null);
+
+ expect(component.refresh).toHaveBeenCalled();
+ });
+
+ it('should refresh on node restore event', () => {
+ contentService.nodeRestored.next(null);
+
+ expect(component.refresh).toHaveBeenCalled();
+ });
});
describe('Node navigation', () => {
@@ -238,4 +288,35 @@ describe('Favorites Routed Component', () => {
expect(component.documentList.reload).toHaveBeenCalled();
});
});
+
+ describe('onSortingChanged', () => {
+ it('should save sorting input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {
+ key: 'some-name',
+ direction: 'some-direction'
+ }
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'some-name');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'some-direction');
+ });
+
+ it('should save default sorting when no input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {}
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
+ });
+ });
});
diff --git a/src/app/components/files/files.component.spec.ts b/src/app/components/files/files.component.spec.ts
index 1538f5978..e45aa7d7d 100644
--- a/src/app/components/files/files.component.spec.ts
+++ b/src/app/components/files/files.component.spec.ts
@@ -24,16 +24,28 @@
*/
import { Observable } from 'rxjs/Rx';
-import { Router } from '@angular/router';
-import { RouterTestingModule } from '@angular/router/testing';
import { TestBed, async } from '@angular/core/testing';
-import { UploadService, NodesApiService, ContentService } from '@alfresco/adf-core';
-
-import { CommonModule } from '../../common/common.module';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { Router, ActivatedRoute } from '@angular/router';
+import { RouterTestingModule } from '@angular/router/testing';
+import { HttpClientModule } from '@angular/common/http';
+import { TranslateModule } from '@ngx-translate/core';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import {
+ NotificationService, TranslationService, TranslationMock,
+ NodesApiService, AlfrescoApiService, ContentService,
+ UserPreferencesService, LogService, AppConfigService,
+ StorageService, CookieService, ThumbnailService, AuthenticationService,
+ TimeAgoPipe, NodeNameTooltipPipe, FileSizePipe, NodeFavoriteDirective,
+ DataTableComponent, UploadService
+} from '@alfresco/adf-core';
+import { DocumentListComponent } from '@alfresco/adf-content-services';
+import { MatMenuModule, MatSnackBarModule, MatIconModule, MatDialogModule } from '@angular/material';
+import { DocumentListService } from '@alfresco/adf-content-services';
import { ContentManagementService } from '../../common/services/content-management.service';
import { BrowsingFilesService } from '../../common/services/browsing-files.service';
import { NodeActionsService } from '../../common/services/node-actions.service';
-import { GenericErrorComponent } from '../generic-error/generic-error.component';
+
import { FilesComponent } from './files.component';
describe('FilesComponent', () => {
@@ -48,17 +60,50 @@ describe('FilesComponent', () => {
let router: Router;
let browsingFilesService: BrowsingFilesService;
let nodeActionsService: NodeActionsService;
+ let preferenceService: UserPreferencesService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
+ MatMenuModule,
+ NoopAnimationsModule,
+ HttpClientModule,
+ TranslateModule.forRoot(),
RouterTestingModule,
- CommonModule
+ MatSnackBarModule, MatIconModule,
+ MatDialogModule
],
declarations: [
FilesComponent,
- GenericErrorComponent
- ]
+ DataTableComponent,
+ TimeAgoPipe,
+ NodeNameTooltipPipe,
+ NodeFavoriteDirective,
+ DocumentListComponent,
+ FileSizePipe
+ ],
+ providers: [
+ { provide: ActivatedRoute, useValue: {
+ params: Observable.of({ folderId: 'someId' }),
+ snapshot: { data: { preferencePrefix: 'prefix' } }
+ } } ,
+ { provide: TranslationService, useClass: TranslationMock },
+ AuthenticationService,
+ UserPreferencesService,
+ AppConfigService, StorageService, CookieService,
+ AlfrescoApiService,
+ LogService,
+ NotificationService,
+ ContentManagementService,
+ ContentService,
+ NodesApiService,
+ DocumentListService,
+ ThumbnailService,
+ NodeActionsService,
+ UploadService,
+ BrowsingFilesService
+ ],
+ schemas: [ NO_ERRORS_SCHEMA ]
}).compileComponents()
.then(() => {
@@ -72,6 +117,7 @@ describe('FilesComponent', () => {
alfrescoContentService = TestBed.get(ContentService);
browsingFilesService = TestBed.get(BrowsingFilesService);
nodeActionsService = TestBed.get(NodeActionsService);
+ preferenceService = TestBed.get(UserPreferencesService);
});
}));
@@ -454,4 +500,55 @@ describe('FilesComponent', () => {
expect(router.navigate).toHaveBeenCalledWith(['./'], jasmine.any(Object));
});
});
+
+ describe('isSiteContainer', () => {
+ it('should return false if node has no aspectNames', () => {
+ const mock = { aspectNames: [] };
+
+ expect(component.isSiteContainer(mock)).toBe(false);
+ });
+
+ it('should return false if node is not site container', () => {
+ const mock = { aspectNames: ['something-else'] };
+
+ expect(component.isSiteContainer(mock)).toBe(false);
+ });
+
+ it('should return true if node is a site container', () => {
+ const mock = { aspectNames: [ 'st:siteContainer' ] };
+
+ expect(component.isSiteContainer(mock)).toBe(true);
+ });
+ });
+
+ describe('onSortingChanged', () => {
+ it('should save sorting input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {
+ key: 'some-name',
+ direction: 'some-direction'
+ }
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'some-name');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'some-direction');
+ });
+
+ it('should save default sorting when no input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {}
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
+ });
+ });
});
diff --git a/src/app/components/libraries/libraries.component.spec.ts b/src/app/components/libraries/libraries.component.spec.ts
index 6498569a7..706054fbb 100644
--- a/src/app/components/libraries/libraries.component.spec.ts
+++ b/src/app/components/libraries/libraries.component.spec.ts
@@ -23,15 +23,26 @@
* along with Alfresco. If not, see .
*/
-import { Router } from '@angular/router';
-import { RouterTestingModule } from '@angular/router/testing';
import { TestBed, async } from '@angular/core/testing';
import { Observable } from 'rxjs/Rx';
-
-import { CoreModule , NodesApiService, AlfrescoApiService} from '@alfresco/adf-core';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { Router, ActivatedRoute } from '@angular/router';
+import { RouterTestingModule } from '@angular/router/testing';
+import { HttpClientModule } from '@angular/common/http';
+import {
+ NotificationService, TranslationService, TranslationMock,
+ NodesApiService, AlfrescoApiService, ContentService,
+ UserPreferencesService, LogService, AppConfigService,
+ StorageService, CookieService, ThumbnailService, AuthenticationService,
+ TimeAgoPipe, NodeNameTooltipPipe, NodeFavoriteDirective, DataTableComponent
+} from '@alfresco/adf-core';
+import { DocumentListComponent } from '@alfresco/adf-content-services';
+import { TranslateModule } from '@ngx-translate/core';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { MatMenuModule, MatSnackBarModule, MatIconModule } from '@angular/material';
+import { DocumentListService } from '@alfresco/adf-content-services';
import { ShareDataTableAdapter } from '@alfresco/adf-content-services';
-import { CommonModule } from '../../common/common.module';
import { LibrariesComponent } from './libraries.component';
describe('Libraries Routed Component', () => {
@@ -40,6 +51,7 @@ describe('Libraries Routed Component', () => {
let nodesApi: NodesApiService;
let alfrescoApi: AlfrescoApiService;
let router: Router;
+ let preferenceService: UserPreferencesService;
let page;
let node;
@@ -62,13 +74,38 @@ describe('Libraries Routed Component', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
- CoreModule,
+ MatMenuModule,
+ NoopAnimationsModule,
+ HttpClientModule,
+ TranslateModule.forRoot(),
RouterTestingModule,
- CommonModule
+ MatSnackBarModule, MatIconModule
],
declarations: [
+ DataTableComponent,
+ TimeAgoPipe,
+ NodeNameTooltipPipe,
+ NodeFavoriteDirective,
+ DocumentListComponent,
LibrariesComponent
- ]
+ ],
+ providers: [
+ { provide: ActivatedRoute, useValue: {
+ snapshot: { data: { preferencePrefix: 'prefix' } }
+ } } ,
+ { provide: TranslationService, useClass: TranslationMock },
+ AuthenticationService,
+ UserPreferencesService,
+ AppConfigService, StorageService, CookieService,
+ AlfrescoApiService,
+ LogService,
+ NotificationService,
+ ContentService,
+ NodesApiService,
+ DocumentListService,
+ ThumbnailService
+ ],
+ schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents().then(() => {
fixture = TestBed.createComponent(LibrariesComponent);
@@ -77,6 +114,7 @@ describe('Libraries Routed Component', () => {
nodesApi = TestBed.get(NodesApiService);
alfrescoApi = TestBed.get(AlfrescoApiService);
router = TestBed.get(Router);
+ preferenceService = TestBed.get(UserPreferencesService);
});
}));
@@ -191,4 +229,35 @@ describe('Libraries Routed Component', () => {
expect(component.navigate).not.toHaveBeenCalled();
});
});
+
+ describe('onSortingChanged', () => {
+ it('should save sorting input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {
+ key: 'some-name',
+ direction: 'some-direction'
+ }
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'some-name');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'some-direction');
+ });
+
+ it('should save default sorting when no input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {}
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
+ });
+ });
});
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 c90ad6164..09ed4bf0f 100644
--- a/src/app/components/recent-files/recent-files.component.spec.ts
+++ b/src/app/components/recent-files/recent-files.component.spec.ts
@@ -23,15 +23,25 @@
* along with Alfresco. If not, see .
*/
-import { Router } from '@angular/router';
-import { RouterTestingModule } from '@angular/router/testing';
import { TestBed, async } from '@angular/core/testing';
-
-import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
-
-import { CommonModule } from '../../common/common.module';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { Router, ActivatedRoute } from '@angular/router';
+import { RouterTestingModule } from '@angular/router/testing';
+import { HttpClientModule } from '@angular/common/http';
+import {
+ NotificationService, TranslationService, TranslationMock,
+ NodesApiService, AlfrescoApiService, ContentService,
+ UserPreferencesService, LogService, AppConfigService,
+ StorageService, CookieService, ThumbnailService, AuthenticationService,
+ TimeAgoPipe, NodeNameTooltipPipe, NodeFavoriteDirective, DataTableComponent
+} from '@alfresco/adf-core';
+import { DocumentListComponent } from '@alfresco/adf-content-services';
+import { TranslateModule } from '@ngx-translate/core';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { MatMenuModule, MatSnackBarModule, MatIconModule } from '@angular/material';
+import { DocumentListService } from '@alfresco/adf-content-services';
import { ContentManagementService } from '../../common/services/content-management.service';
-import { LocationLinkComponent } from '../location-link/location-link.component';
+
import { RecentFilesComponent } from './recent-files.component';
describe('RecentFiles Routed Component', () => {
@@ -40,6 +50,7 @@ describe('RecentFiles Routed Component', () => {
let router: Router;
let alfrescoApi: AlfrescoApiService;
let contentService: ContentManagementService;
+ let preferenceService: UserPreferencesService;
let page;
let person;
@@ -57,14 +68,39 @@ describe('RecentFiles Routed Component', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
- CoreModule,
+ MatMenuModule,
+ NoopAnimationsModule,
+ HttpClientModule,
+ TranslateModule.forRoot(),
RouterTestingModule,
- CommonModule
+ MatSnackBarModule, MatIconModule
],
declarations: [
- LocationLinkComponent,
+ DataTableComponent,
+ TimeAgoPipe,
+ NodeNameTooltipPipe,
+ NodeFavoriteDirective,
+ DocumentListComponent,
RecentFilesComponent
- ]
+ ],
+ providers: [
+ { provide: ActivatedRoute, useValue: {
+ snapshot: { data: { preferencePrefix: 'prefix' } }
+ } } ,
+ { provide: TranslationService, useClass: TranslationMock },
+ AuthenticationService,
+ UserPreferencesService,
+ AppConfigService, StorageService, CookieService,
+ AlfrescoApiService,
+ LogService,
+ NotificationService,
+ ContentManagementService,
+ ContentService,
+ NodesApiService,
+ DocumentListService,
+ ThumbnailService
+ ],
+ schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents().then(() => {
fixture = TestBed.createComponent(RecentFilesComponent);
@@ -72,6 +108,7 @@ describe('RecentFiles Routed Component', () => {
router = TestBed.get(Router);
contentService = TestBed.get(ContentManagementService);
+ preferenceService = TestBed.get(UserPreferencesService);
alfrescoApi = TestBed.get(AlfrescoApiService);
});
}));
@@ -150,4 +187,35 @@ describe('RecentFiles Routed Component', () => {
expect(component.documentList.reload).toHaveBeenCalled();
});
});
+
+ describe('onSortingChanged', () => {
+ it('should save sorting input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {
+ key: 'some-name',
+ direction: 'some-direction'
+ }
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'some-name');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'some-direction');
+ });
+
+ it('should save default sorting when no input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {}
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
+ });
+ });
});
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 cca450e60..554915ce1 100644
--- a/src/app/components/shared-files/shared-files.component.spec.ts
+++ b/src/app/components/shared-files/shared-files.component.spec.ts
@@ -23,15 +23,25 @@
* along with Alfresco. If not, see .
*/
-import { Router } from '@angular/router';
import { TestBed, async, fakeAsync, tick } from '@angular/core/testing';
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { Router, ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
-
-import { AlfrescoApiService } from '@alfresco/adf-core';
-
-import { CommonModule } from '../../common/common.module';
+import { HttpClientModule } from '@angular/common/http';
+import {
+ NotificationService, TranslationService, TranslationMock,
+ NodesApiService, AlfrescoApiService, ContentService,
+ UserPreferencesService, LogService, AppConfigService,
+ StorageService, CookieService, ThumbnailService, AuthenticationService,
+ TimeAgoPipe, NodeNameTooltipPipe, NodeFavoriteDirective,DataTableComponent
+} from '@alfresco/adf-core';
+import { DocumentListComponent } from '@alfresco/adf-content-services';
+import { TranslateModule } from '@ngx-translate/core';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { MatMenuModule, MatSnackBarModule, MatIconModule } from '@angular/material';
+import { DocumentListService } from '@alfresco/adf-content-services';
import { ContentManagementService } from '../../common/services/content-management.service';
-import { LocationLinkComponent } from '../location-link/location-link.component';
+
import { SharedFilesComponent } from './shared-files.component';
describe('SharedFilesComponent', () => {
@@ -40,6 +50,7 @@ describe('SharedFilesComponent', () => {
let contentService: ContentManagementService;
let nodeService;
let alfrescoApi: AlfrescoApiService;
+ let preferenceService: UserPreferencesService;
let router: Router;
let page;
@@ -56,13 +67,39 @@ describe('SharedFilesComponent', () => {
TestBed
.configureTestingModule({
imports: [
+ MatMenuModule,
+ NoopAnimationsModule,
+ HttpClientModule,
+ TranslateModule.forRoot(),
RouterTestingModule,
- CommonModule
+ MatSnackBarModule, MatIconModule
],
declarations: [
- LocationLinkComponent,
+ DataTableComponent,
+ TimeAgoPipe,
+ NodeNameTooltipPipe,
+ NodeFavoriteDirective,
+ DocumentListComponent,
SharedFilesComponent
- ]
+ ],
+ providers: [
+ { provide: ActivatedRoute, useValue: {
+ snapshot: { data: { preferencePrefix: 'prefix' } }
+ } } ,
+ { provide: TranslationService, useClass: TranslationMock },
+ AuthenticationService,
+ UserPreferencesService,
+ AppConfigService, StorageService, CookieService,
+ AlfrescoApiService,
+ LogService,
+ NotificationService,
+ ContentManagementService,
+ ContentService,
+ NodesApiService,
+ DocumentListService,
+ ThumbnailService
+ ],
+ schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents()
.then(() => {
@@ -72,6 +109,7 @@ describe('SharedFilesComponent', () => {
contentService = TestBed.get(ContentManagementService);
alfrescoApi = TestBed.get(AlfrescoApiService);
nodeService = alfrescoApi.getInstance().nodes;
+ preferenceService = TestBed.get(UserPreferencesService);
router = TestBed.get(Router);
});
@@ -160,4 +198,35 @@ describe('SharedFilesComponent', () => {
expect(component.documentList.reload).toHaveBeenCalled();
});
});
+
+ describe('onSortingChanged', () => {
+ it('should save sorting input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {
+ key: 'some-name',
+ direction: 'some-direction'
+ }
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'some-name');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'some-direction');
+ });
+
+ it('should save default sorting when no input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {}
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
+ });
+ });
});
diff --git a/src/app/components/trashcan/trashcan.component.spec.ts b/src/app/components/trashcan/trashcan.component.spec.ts
index 0ec8dc934..196d65ced 100644
--- a/src/app/components/trashcan/trashcan.component.spec.ts
+++ b/src/app/components/trashcan/trashcan.component.spec.ts
@@ -22,19 +22,34 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see .
*/
+import { NO_ERRORS_SCHEMA } from '@angular/core';
+import { ActivatedRoute } from '@angular/router';
import { RouterTestingModule } from '@angular/router/testing';
+import { HttpClientModule } from '@angular/common/http';
import { TestBed, async } from '@angular/core/testing';
-import { CoreModule, AlfrescoApiService } from '@alfresco/adf-core';
-import { TrashcanComponent } from './trashcan.component';
-import { CommonModule } from '../../common/common.module';
-import { LocationLinkComponent } from '../location-link/location-link.component';
+import {
+ NotificationService, TranslationService, TranslationMock,
+ NodesApiService, AlfrescoApiService, ContentService,
+ UserPreferencesService, LogService, AppConfigService,
+ StorageService, CookieService, ThumbnailService,
+ AuthenticationService, TimeAgoPipe, NodeNameTooltipPipe,
+ NodeFavoriteDirective, DataTableComponent
+} from '@alfresco/adf-core';
+import { DocumentListComponent } from '@alfresco/adf-content-services';
+import { TranslateModule } from '@ngx-translate/core';
+import { NoopAnimationsModule } from '@angular/platform-browser/animations';
+import { MatMenuModule, MatSnackBarModule, MatIconModule } from '@angular/material';
+import { DocumentListService } from '@alfresco/adf-content-services';
import { ContentManagementService } from '../../common/services/content-management.service';
+import { TrashcanComponent } from './trashcan.component';
+
describe('TrashcanComponent', () => {
let fixture;
let component;
let alfrescoApi: AlfrescoApiService;
let contentService: ContentManagementService;
+ let preferenceService: UserPreferencesService;
let page;
beforeEach(() => {
@@ -49,17 +64,39 @@ describe('TrashcanComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
+ MatMenuModule,
+ NoopAnimationsModule,
+ HttpClientModule,
+ TranslateModule.forRoot(),
RouterTestingModule,
- CoreModule,
- CommonModule
+ MatSnackBarModule, MatIconModule
],
declarations: [
- LocationLinkComponent,
+ DataTableComponent,
+ TimeAgoPipe,
+ NodeNameTooltipPipe,
+ NodeFavoriteDirective,
+ DocumentListComponent,
TrashcanComponent
],
providers: [
- ContentManagementService
- ]
+ { provide: ActivatedRoute, useValue: {
+ snapshot: { data: { preferencePrefix: 'prefix' } }
+ } } ,
+ { provide: TranslationService, useClass: TranslationMock },
+ AuthenticationService,
+ UserPreferencesService,
+ AppConfigService, StorageService, CookieService,
+ AlfrescoApiService,
+ LogService,
+ NotificationService,
+ ContentManagementService,
+ ContentService,
+ NodesApiService,
+ DocumentListService,
+ ThumbnailService
+ ],
+ schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents()
.then(() => {
@@ -68,6 +105,7 @@ describe('TrashcanComponent', () => {
alfrescoApi = TestBed.get(AlfrescoApiService);
contentService = TestBed.get(ContentManagementService);
+ preferenceService = TestBed.get(UserPreferencesService);
component.documentList = {
loadTrashcan: jasmine.createSpy('loadTrashcan'),
@@ -102,4 +140,35 @@ describe('TrashcanComponent', () => {
expect(component.documentList.resetSelection).toHaveBeenCalled();
});
});
+
+ describe('onSortingChanged', () => {
+ it('should save sorting input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {
+ key: 'some-name',
+ direction: 'some-direction'
+ }
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'some-name');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'some-direction');
+ });
+
+ it('should save default sorting when no input', () => {
+ spyOn(preferenceService, 'set');
+
+ const event = {
+ detail: {}
+ };
+
+ component.onSortingChanged(event);
+
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'archivedAt');
+ expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
+ });
+ });
});