mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[APM-7] Feature enhancement for the create and edit folder directive (#3179)
* Add observable menu open state to the sidenav-layout component * add documentation, fix inversed value * Add success events to folder create/edit directives * Overridable dialog titles for the directives * Update the documentation
This commit is contained in:
committed by
Eugenio Romano
parent
21ad4c2894
commit
ee9393caf0
@@ -17,7 +17,7 @@
|
||||
|
||||
import { HttpClientModule } from '@angular/common/http';
|
||||
import { Component } from '@angular/core';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { MatDialog, MatDialogModule } from '@angular/material';
|
||||
import { By } from '@angular/platform-browser';
|
||||
|
||||
@@ -27,12 +27,19 @@ import { Observable } from 'rxjs/Observable';
|
||||
|
||||
import { ContentService, TranslateLoaderService, DirectiveModule } from '@alfresco/adf-core';
|
||||
import { FolderEditDirective } from './folder-edit.directive';
|
||||
import { MinimalNodeEntryEntity } from 'alfresco-js-api';
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
|
||||
@Component({
|
||||
template: '<div [adf-edit-folder]="folder"></div>'
|
||||
template: '<div [adf-edit-folder]="folder" (success)="success($event)" title="edit-title"></div>'
|
||||
})
|
||||
class TestComponent {
|
||||
folder = {};
|
||||
public successParameter: MinimalNodeEntryEntity = null;
|
||||
|
||||
success(node: MinimalNodeEntryEntity) {
|
||||
this.successParameter = node;
|
||||
}
|
||||
}
|
||||
|
||||
describe('FolderEditDirective', () => {
|
||||
@@ -85,7 +92,11 @@ describe('FolderEditDirective', () => {
|
||||
node = { entry: { id: 'folderId' } };
|
||||
|
||||
dialogRefMock = {
|
||||
afterClosed: val => Observable.of(val)
|
||||
afterClosed: val => Observable.of(val),
|
||||
componentInstance: {
|
||||
error: new Subject<any>(),
|
||||
success: new Subject<MinimalNodeEntryEntity>()
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(dialog, 'open').and.returnValue(dialogRefMock);
|
||||
@@ -114,4 +125,29 @@ describe('FolderEditDirective', () => {
|
||||
expect(contentService.folderEdit.next).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
it('should emit success event with node if the folder creation was successful', async(() => {
|
||||
const testNode = <MinimalNodeEntryEntity> {};
|
||||
fixture.detectChanges();
|
||||
|
||||
element.triggerEventHandler('click', event);
|
||||
dialogRefMock.componentInstance.success.next(testNode);
|
||||
|
||||
fixture.whenStable().then(() => {
|
||||
expect(fixture.componentInstance.successParameter).toBe(testNode);
|
||||
});
|
||||
}));
|
||||
|
||||
it('should open the dialog with the proper title', async(() => {
|
||||
fixture.detectChanges();
|
||||
element.triggerEventHandler('click', event);
|
||||
|
||||
expect(dialog.open).toHaveBeenCalledWith(jasmine.any(Function), {
|
||||
data: {
|
||||
folder: jasmine.any(Object),
|
||||
editTitle: 'edit-title'
|
||||
},
|
||||
width: jasmine.any(String)
|
||||
});
|
||||
}));
|
||||
});
|
||||
|
Reference in New Issue
Block a user