diff --git a/demo-shell/src/app/components/files/files.component.html b/demo-shell/src/app/components/files/files.component.html
index f41a9171cc..78be33c5a3 100644
--- a/demo-shell/src/app/components/files/files.component.html
+++ b/demo-shell/src/app/components/files/files.component.html
@@ -198,7 +198,6 @@
-
-
-
-
-
-
{
+describe('ContentAction', () => {
let documentList: DocumentListComponent;
let actionList: ContentActionListComponent;
@@ -133,25 +130,45 @@ fdescribe('ContentAction', () => {
expect(model.handler).toBe(handler);
});
- it('should require target to get system handler', () => {
+ it('should create document and folder action when there is no target', () => {
spyOn(folderActions, 'getHandler').and.stub();
spyOn(documentActions, 'getHandler').and.stub();
let action = new ContentActionComponent(actionList, documentActions, folderActions);
action.handler = '';
+ action.ngOnInit();
+ expect(documentList.actions.length).toBe(2);
+ expect(folderActions.getHandler).toHaveBeenCalled();
+ expect(documentActions.getHandler).toHaveBeenCalled();
+ });
+
+ it('should create document action when target is document', () => {
+ spyOn(folderActions, 'getHandler').and.stub();
+ spyOn(documentActions, 'getHandler').and.stub();
+
+ let action = new ContentActionComponent(actionList, documentActions, folderActions);
+ action.handler = '';
+ action.target = 'document';
+
action.ngOnInit();
expect(documentList.actions.length).toBe(1);
expect(folderActions.getHandler).not.toHaveBeenCalled();
- expect(documentActions.getHandler).not.toHaveBeenCalled();
-
- action.target = 'document';
- action.ngOnInit();
expect(documentActions.getHandler).toHaveBeenCalled();
+ });
+ it('should create folder action when target is folder', () => {
+ spyOn(folderActions, 'getHandler').and.stub();
+ spyOn(documentActions, 'getHandler').and.stub();
+
+ let action = new ContentActionComponent(actionList, documentActions, folderActions);
+ action.handler = '';
action.target = 'folder';
+
action.ngOnInit();
+ expect(documentList.actions.length).toBe(1);
expect(folderActions.getHandler).toHaveBeenCalled();
+ expect(documentActions.getHandler).not.toHaveBeenCalled();
});
it('should be case insensitive for document target', () => {
diff --git a/lib/content-services/document-list/components/content-action/content-action.component.ts b/lib/content-services/document-list/components/content-action/content-action.component.ts
index 018277674f..d3edea6980 100644
--- a/lib/content-services/document-list/components/content-action/content-action.component.ts
+++ b/lib/content-services/document-list/components/content-action/content-action.component.ts
@@ -90,13 +90,11 @@ export class ContentActionComponent implements OnInit {
}
ngOnInit() {
- if (this.handler) {
- if (this.target === 'all') {
- this.generateAction('folder');
- this.generateAction('document');
- } else {
- this.generateAction(this.target);
- }
+ if (this.target === 'all') {
+ this.generateAction('folder');
+ this.generateAction('document');
+ } else {
+ this.generateAction(this.target);
}
}
@@ -116,8 +114,9 @@ export class ContentActionComponent implements OnInit {
target: target,
disabled: this.disabled
});
-
- model.handler = this.getSystemHandler(target, this.handler);
+ if (this.handler) {
+ model.handler = this.getSystemHandler(target, this.handler);
+ }
if (this.execute) {
model.execute = (value: any): void => {