[ACA-866] Trash - Undo deleted node notification not reflected (#88)

This commit is contained in:
Cilibiu Bogdan
2017-11-27 09:50:58 +00:00
committed by Denys Vuika
parent b1b9e04db6
commit 319594d63b
2 changed files with 34 additions and 2 deletions
@@ -20,11 +20,13 @@ 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 { ContentManagementService } from '../../common/services/content-management.service';
describe('TrashcanComponent', () => {
let fixture;
let component;
let alfrescoApi: AlfrescoApiService;
let contentService: ContentManagementService;
let page;
beforeEach(() => {
@@ -45,6 +47,9 @@ describe('TrashcanComponent', () => {
declarations: [
LocationLinkComponent,
TrashcanComponent
],
providers: [
ContentManagementService
]
})
.compileComponents()
@@ -53,6 +58,7 @@ describe('TrashcanComponent', () => {
component = fixture.componentInstance;
alfrescoApi = TestBed.get(AlfrescoApiService);
contentService = TestBed.get(ContentManagementService);
component.documentList = {
loadTrashcan: jasmine.createSpy('loadTrashcan'),
@@ -65,6 +71,17 @@ describe('TrashcanComponent', () => {
spyOn(alfrescoApi.nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(page));
});
describe('onRestoreNode()', () => {
it('should call refresh()', () => {
spyOn(component, 'refresh');
fixture.detectChanges();
contentService.restoreNode.next();
expect(component.refresh).toHaveBeenCalled();
});
});
describe('refresh()', () => {
it('calls child component to reload', () => {
component.refresh();
@@ -15,17 +15,32 @@
* limitations under the License.
*/
import { Component, ViewChild } from '@angular/core';
import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs/Rx';
import { DocumentListComponent } from '@alfresco/adf-content-services';
import { ContentManagementService } from '../../common/services/content-management.service';
@Component({
templateUrl: './trashcan.component.html'
})
export class TrashcanComponent {
export class TrashcanComponent implements OnInit, OnDestroy {
private subscriptions: Subscription[] = [];
@ViewChild(DocumentListComponent) documentList;
constructor(private contentManagementService: ContentManagementService) {}
ngOnInit() {
this.subscriptions.push(this.contentManagementService.restoreNode.subscribe(() => this.refresh()));
}
refresh(): void {
this.documentList.loadTrashcan();
this.documentList.resetSelection();
}
ngOnDestroy() {
this.subscriptions.forEach(s => s.unsubscribe());
}
}