mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
add test document menu component (#1802)
This commit is contained in:
parent
a6c83f9c64
commit
364e36f857
@ -0,0 +1,117 @@
|
|||||||
|
/*!
|
||||||
|
* @license
|
||||||
|
* Copyright 2016 Alfresco Software, Ltd.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import {
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoApiService,
|
||||||
|
CoreModule,
|
||||||
|
LogService
|
||||||
|
} from 'ng2-alfresco-core';
|
||||||
|
import { DocumentListService } from './../services/document-list.service';
|
||||||
|
import { DocumentMenuActionComponent } from './document-menu-action.component';
|
||||||
|
|
||||||
|
declare let jasmine: any;
|
||||||
|
|
||||||
|
describe('Document menu action', () => {
|
||||||
|
|
||||||
|
let component: DocumentMenuActionComponent;
|
||||||
|
let fixture: ComponentFixture<DocumentMenuActionComponent>;
|
||||||
|
let element: HTMLElement;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
CoreModule
|
||||||
|
],
|
||||||
|
declarations: [DocumentMenuActionComponent],
|
||||||
|
providers: [
|
||||||
|
AlfrescoSettingsService,
|
||||||
|
AlfrescoAuthenticationService,
|
||||||
|
AlfrescoApiService,
|
||||||
|
LogService,
|
||||||
|
DocumentListService
|
||||||
|
]
|
||||||
|
});
|
||||||
|
|
||||||
|
TestBed.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(DocumentMenuActionComponent);
|
||||||
|
|
||||||
|
element = fixture.nativeElement;
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
jasmine.Ajax.install();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
jasmine.Ajax.uninstall();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('Folder creation', () => {
|
||||||
|
|
||||||
|
it('should createFolder fire a success event if the folder has been created', (done) => {
|
||||||
|
|
||||||
|
component.showDialog();
|
||||||
|
|
||||||
|
component.createFolder('test-folder');
|
||||||
|
|
||||||
|
component.success.subscribe(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'application/json',
|
||||||
|
responseText: JSON.stringify({
|
||||||
|
'entry': {
|
||||||
|
'aspectNames': ['cm:auditable'],
|
||||||
|
'createdAt': '2017-04-03T11:34:35.708+0000',
|
||||||
|
'isFolder': true,
|
||||||
|
'isFile': false,
|
||||||
|
'createdByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
||||||
|
'modifiedAt': '2017-04-03T11:34:35.708+0000',
|
||||||
|
'modifiedByUser': {'id': 'admin', 'displayName': 'Administrator'},
|
||||||
|
'name': 'test-folder2',
|
||||||
|
'id': 'c0284dc3-841d-48b2-955c-bcb2218e2b03',
|
||||||
|
'nodeType': 'cm:folder',
|
||||||
|
'parentId': '1ee81bf8-52d6-4cfc-a924-1efbc79306bf'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should createFolder fire an error event if the folder has not been created', (done) => {
|
||||||
|
|
||||||
|
component.showDialog();
|
||||||
|
|
||||||
|
component.createFolder('test-folder');
|
||||||
|
|
||||||
|
component.error.subscribe(() => {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
|
jasmine.Ajax.requests.mostRecent().respondWith({
|
||||||
|
status: 403
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -71,8 +71,8 @@ export class DocumentMenuActionComponent {
|
|||||||
this.success.emit({node: res.entry});
|
this.success.emit({node: res.entry});
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
let errorMessagePlaceholder = this.getErrorMessage(error.response);
|
if (error.response) {
|
||||||
if (errorMessagePlaceholder) {
|
let errorMessagePlaceholder = this.getErrorMessage(error.response);
|
||||||
this.message = this.formatString(errorMessagePlaceholder, [name]);
|
this.message = this.formatString(errorMessagePlaceholder, [name]);
|
||||||
this.error.emit({message: this.message});
|
this.error.emit({message: this.message});
|
||||||
this.logService.error(this.message);
|
this.logService.error(this.message);
|
||||||
|
@ -73,8 +73,6 @@ describe('Test ng2-alfresco-viewer ViewerComponent', () => {
|
|||||||
component.showToolbar = true;
|
component.showToolbar = true;
|
||||||
component.urlFile = 'base/src/assets/fake-test-file.pdf';
|
component.urlFile = 'base/src/assets/fake-test-file.pdf';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user