mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
Browsing Files - unit tests granular dependencies (#199)
This commit is contained in:
committed by
Denys Vuika
parent
114455e5c9
commit
4d7b6d3271
@@ -23,14 +23,26 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 = <any>{
|
||||
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 = <any>{
|
||||
detail: {}
|
||||
};
|
||||
|
||||
component.onSortingChanged(event);
|
||||
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -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 = <any>{
|
||||
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 = <any>{
|
||||
detail: {}
|
||||
};
|
||||
|
||||
component.onSortingChanged(event);
|
||||
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -23,15 +23,26 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 = <any>{
|
||||
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 = <any>{
|
||||
detail: {}
|
||||
};
|
||||
|
||||
component.onSortingChanged(event);
|
||||
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -23,15 +23,25 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 = <any>{
|
||||
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 = <any>{
|
||||
detail: {}
|
||||
};
|
||||
|
||||
component.onSortingChanged(event);
|
||||
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -23,15 +23,25 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 = <any>{
|
||||
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 = <any>{
|
||||
detail: {}
|
||||
};
|
||||
|
||||
component.onSortingChanged(event);
|
||||
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'modifiedAt');
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -22,19 +22,34 @@
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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 = <any>{
|
||||
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 = <any>{
|
||||
detail: {}
|
||||
};
|
||||
|
||||
component.onSortingChanged(event);
|
||||
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.key', 'archivedAt');
|
||||
expect(preferenceService.set).toHaveBeenCalledWith('prefix.sorting.direction', 'desc');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user