當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript adf-core.CoreModule類代碼示例

本文整理匯總了TypeScript中@alfresco/adf-core.CoreModule的典型用法代碼示例。如果您正苦於以下問題:TypeScript CoreModule類的具體用法?TypeScript CoreModule怎麽用?TypeScript CoreModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了CoreModule類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: describe

    describe('Injecting custom colums for tasklist - CustomTaskListComponent', () => {
        let fixtureCustom: ComponentFixture<CustomTaskListComponent>;
        let componentCustom: CustomTaskListComponent;

        setupTestBed({
            imports: [CoreModule.forRoot()],
            declarations: [TaskListCloudComponent, CustomTaskListComponent],
            providers: [TaskListCloudService]
        });

        beforeEach(() => {
            fixtureCustom = TestBed.createComponent(CustomTaskListComponent);
            fixtureCustom.detectChanges();
            componentCustom = fixtureCustom.componentInstance;
        });

        afterEach(() => {
            fixtureCustom.destroy();
        });

        it('should create instance of CustomTaskListComponent', () => {
            expect(componentCustom instanceof CustomTaskListComponent).toBe(true, 'should create CustomTaskListComponent');
        });

        it('should fetch custom schemaColumn from html', () => {
            fixture.detectChanges();
            expect(componentCustom.taskList.columnList).toBeDefined();
            expect(componentCustom.taskList.columns[0]['title']).toEqual('ADF_CLOUD_TASK_LIST.PROPERTIES.NAME');
            expect(componentCustom.taskList.columns[1]['title']).toEqual('ADF_CLOUD_TASK_LIST.PROPERTIES.CREATED');
            expect(componentCustom.taskList.columns.length).toEqual(3);
        });

    });
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:33,代碼來源:task-list-cloud.component.spec.ts

示例2: beforeEach

 beforeEach(() => {
   TestBed.configureTestingModule({
       imports: [CoreModule.forRoot()],
       declarations: [HomeComponent],
       schemas: [CUSTOM_ELEMENTS_SCHEMA]
   });
 });
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:7,代碼來源:home.component.spec.ts

示例3: describe

describe('CustomProcessListComponent', () => {
    let fixture: ComponentFixture<CustomProcessListComponent>;
    let component: CustomProcessListComponent;

    setupTestBed({
        imports: [CoreModule.forRoot()],
        declarations: [ProcessInstanceListComponent, CustomProcessListComponent],
        providers: [ProcessService]
    });

    beforeEach(() => {
        fixture = TestBed.createComponent(CustomProcessListComponent);
        fixture.detectChanges();
        component = fixture.componentInstance;
    });

    it('should create instance of CustomProcessListComponent', () => {
        expect(component instanceof CustomProcessListComponent).toBe(true, 'should create CustomProcessListComponent');
    });

    it('should fetch custom schemaColumn from html', () => {
        fixture.detectChanges();
        expect(component.processList.columns).toBeDefined();
        expect(component.processList.columns.length).toEqual(3);
        expect(component.processList.columns[1]['title']).toEqual('ADF_PROCESS_LIST.PROPERTIES.END_DATE');
        expect(component.processList.columns[2]['title']).toEqual('ADF_PROCESS_LIST.PROPERTIES.CREATED');
    });
});
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:28,代碼來源:process-list.component.spec.ts

示例4: beforeEach

 beforeEach( async(() => {
     TestBed.configureTestingModule({
         imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule, AppListCloudModule],
         providers: [
             AppsProcessCloudService
         ]
       })
       .overrideComponent(AppListCloudComponent, {
         set: {
           providers: [
             { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
           ]
         }
       }).compileComponents();
 }));
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:15,代碼來源:app-list-cloud.component.spec.ts

示例5: describe

describe('AppsProcessCloudService', () => {

    let service: AppsProcessCloudService;

    setupTestBed({
        imports: [CoreModule.forRoot(), ProcessServiceCloudTestingModule],
        providers: [AppsProcessCloudService]
    });

    beforeEach(() => {
        service = TestBed.get(AppsProcessCloudService);
    });

    it('should get the deployed applications ', (done) => {
        spyOn(service, 'getDeployedApplicationsByStatus').and.returnValue(of(fakeApplicationInstance));
        service.getDeployedApplicationsByStatus('fake').subscribe(
            (res: ApplicationInstanceModel[]) => {
                expect(res).toBeDefined();
                expect(res.length).toEqual(3);
                expect(res).toEqual(fakeApplicationInstance);
                expect(res[0]).toEqual(fakeApplicationInstance[0]);
                expect(res[0].name).toEqual('application-new-1');
                expect(res[1]).toEqual(fakeApplicationInstance[1]);
                expect(res[1].name).toEqual('application-new-2');
                done();
            }
        );
    });

    it('Should not fetch deployed applications if error occurred', () => {
        const errorResponse = new HttpErrorResponse({
            error: 'Mock Error',
            status: 404, statusText: 'Not Found'
        });

        spyOn(service, 'getDeployedApplicationsByStatus').and.returnValue(throwError(errorResponse));
        service.getDeployedApplicationsByStatus('fake')
            .subscribe(
                (users) => fail('expected an error, not applications'),
                (error) => {
                    expect(error.status).toEqual(404);
                    expect(error.statusText).toEqual('Not Found');
                    expect(error.error).toEqual('Mock Error');
                }
            );
    });
});
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:47,代碼來源:apps-process-cloud.service.spec.ts

示例6: describe

describe('AttachFileWidgetDialogService', () => {

    let service: AttachFileWidgetDialogService;
    let materialDialog: MatDialog;
    let spyOnDialogOpen: jasmine.Spy;
    let afterOpenObservable: Subject<any>;

    setupTestBed({
        imports: [
            CoreModule.forRoot(),
            ProcessModule.forRoot()
        ]
    });

    beforeEach(() => {
        service = TestBed.get(AttachFileWidgetDialogService);
        materialDialog = TestBed.get(MatDialog);
        spyOnDialogOpen = spyOn(materialDialog, 'open').and.returnValue({
            afterOpen: () => afterOpenObservable,
            afterClosed: () => of({}),
            componentInstance: {
                error: new Subject<any>()
            }
        });
    });

    it('should be able to create the service', () => {
        expect(service).not.toBeNull();
        expect(service).toBeDefined();
    });

    it('should be able to open the dialog when node has permission', () => {
        service.openLogin('fake-title', 'fake-action');
        expect(spyOnDialogOpen).toHaveBeenCalled();
    });

    it('should be able to close the material dialog', () => {
        spyOn(materialDialog, 'closeAll');
        service.close();
        expect(materialDialog.closeAll).toHaveBeenCalled();
    });

});
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:43,代碼來源:attach-file-widget-dialog.service.spec.ts

示例7: describe

describe('DropdownSitesComponent', () => {

    let component: any;
    let fixture: ComponentFixture<DropdownSitesComponent>;
    let debug: DebugElement;
    let element: HTMLElement;
    let siteService: SitesService;

    setupTestBed({
        imports: [
            NoopAnimationsModule,
            CoreModule.forRoot()
        ],
        declarations: [
            DropdownSitesComponent
        ],
        providers: [
            { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }
        ]
    });

    describe('Rendering tests', () => {

        describe('Infinite Loading', () => {

            beforeEach(async(() => {
                siteService = TestBed.get(SitesService);
                fixture = TestBed.createComponent(DropdownSitesComponent);
                debug = fixture.debugElement;
                element = fixture.nativeElement;
                component = fixture.componentInstance;
            }));

            it('Should show loading item if there are more itemes', async(() => {
                spyOn(siteService, 'getSites').and.returnValue(of({
                    'list': {
                        'pagination': {
                            'count': 2,
                            'hasMoreItems': true,
                            'totalItems': 2,
                            'skipCount': 0,
                            'maxItems': 100
                        },
                        'entries': [
                            {
                                'entry': {
                                    'role': 'SiteManager',
                                    'visibility': 'PUBLIC',
                                    'guid': 'fake-1',
                                    'description': 'fake-test-site',
                                    'id': 'fake-test-site',
                                    'preset': 'site-dashboard',
                                    'title': 'fake-test-site'
                                }
                            },
                            {
                                'entry': {
                                    'role': 'SiteManager',
                                    'visibility': 'PUBLIC',
                                    'guid': 'fake-2',
                                    'description': 'This is a Sample Alfresco Team site.',
                                    'id': 'swsdp',
                                    'preset': 'site-dashboard',
                                    'title': 'fake-test-2'
                                }
                            }
                        ]
                    }
                }));

                fixture.detectChanges();
                fixture.whenStable().then(() => {
                    fixture.detectChanges();
                    expect(element.querySelector('[data-automation-id="lsite-loading"]')).toBeDefined();
                });
            }));

            it('Should not show loading item if there are more itemes', async(() => {
                spyOn(siteService, 'getSites').and.returnValue(of({
                    'list': {
                        'pagination': {
                            'count': 2,
                            'hasMoreItems': false,
                            'totalItems': 2,
                            'skipCount': 0,
                            'maxItems': 100
                        },
                        'entries': [
                            {
                                'entry': {
                                    'role': 'SiteManager',
                                    'visibility': 'PUBLIC',
                                    'guid': 'fake-1',
                                    'description': 'fake-test-site',
                                    'id': 'fake-test-site',
                                    'preset': 'site-dashboard',
                                    'title': 'fake-test-site'
                                }
                            },
                            {
//.........這裏部分代碼省略.........
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:101,代碼來源:sites-dropdown.component.spec.ts

示例8: describe

describe('FolderActionsService', () => {

    let service: FolderActionsService;
    let documentListService: DocumentListService;

    setupTestBed({
        imports: [
            CoreModule.forRoot()
        ]
    });

    beforeEach(() => {
        let appConfig: AppConfigService = TestBed.get(AppConfigService);
        appConfig.config.ecmHost = 'http://localhost:9876/ecm';

        let contentService = new ContentService(null, null, null, null);
        let alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService());
        documentListService = new DocumentListService(null, contentService, alfrescoApiService, null, null);
        service = new FolderActionsService(null, documentListService, contentService,  new TranslationMock());
    });

    it('should register custom action handler', () => {
        let handler: ContentActionHandler = function () {
        };
        service.setHandler('<key>', handler);
        expect(service.getHandler('<key>')).toBe(handler);
    });

    it('should not find handler that is not registered', () => {
        expect(service.getHandler('<missing>')).toBeNull();
    });

    it('should be case insensitive for keys', () => {
        let handler: ContentActionHandler = function () {
        };
        service.setHandler('<key>', handler);
        expect(service.getHandler('<KEY>')).toBe(handler);
    });

    it('should not find handler with invalid key', () => {
        expect(service.getHandler(null)).toBeNull();
        expect(service.getHandler('')).toBeNull();
    });

    it('should allow action execution only when service available', () => {
        let folder = new FolderNode();
        expect(service.canExecuteAction(folder)).toBeTruthy();
    });

    it('should allow action execution only for folder nodes', () => {
        expect(service.canExecuteAction(null)).toBeFalsy();
        expect(service.canExecuteAction(new FileNode())).toBeFalsy();
        expect(service.canExecuteAction(new FolderNode())).toBeTruthy();
    });

    it('should set new handler only by key', () => {
        let handler: ContentActionHandler = function () {
        };
        expect(service.setHandler(null, handler)).toBeFalsy();
        expect(service.setHandler('', handler)).toBeFalsy();
        expect(service.setHandler('my-handler', handler)).toBeTruthy();
    });

    it('should register delete action', () => {
        expect(service.getHandler('delete')).toBeDefined();
    });

    it('should not delete the folder node if there are no permissions', (done) => {
        spyOn(documentListService, 'deleteNode').and.callThrough();

        service.permissionEvent.subscribe((permission) => {
            expect(permission).toBeDefined();
            expect(permission.type).toEqual('folder');
            expect(permission.action).toEqual('delete');
            done();
        });

        let folder = new FolderNode();
        service.getHandler('delete')(folder);

    });

    it('should delete the folder node if there is the delete permission', () => {
        spyOn(documentListService, 'deleteNode').and.callFake(() => {
            return new Observable<any>((observer) => {
                observer.next();
                observer.complete();
            });
        });

        let permission = 'delete';
        let folder = new FolderNode();
        let folderWithPermission: any = folder;
        folderWithPermission.entry.allowableOperations = [permission];
        const deleteObservable = service.getHandler('delete')(folderWithPermission, null, permission);

        expect(documentListService.deleteNode).toHaveBeenCalledWith(folder.entry.id);
        expect(deleteObservable.subscribe).toBeDefined();
    });

//.........這裏部分代碼省略.........
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:101,代碼來源:folder-actions.service.spec.ts

示例9: describe

describe('AttachFileWidgetDialogComponent', () => {

    let widget: AttachFileWidgetDialogComponent;
    let fixture: ComponentFixture<AttachFileWidgetDialogComponent>;
    let data: AttachFileWidgetDialogComponentData = {
        title: 'Move along citizen...',
        actionName: 'move',
        selected: new EventEmitter<any>(),
        ecmHost: 'http://fakeUrl.com/'
    };
    let element: HTMLInputElement;
    let authService: AuthenticationService;
    let siteService: SitesService;

    let isLogged = false;

    setupTestBed({
        imports: [
            CoreModule.forRoot(),
            ProcessTestingModule,
            ContentModule.forRoot(),
            RouterTestingModule
        ],
        providers: [
            { provide: MAT_DIALOG_DATA, useValue: data }
        ]
    });

    beforeEach(async(() => {
        fixture = TestBed.createComponent(AttachFileWidgetDialogComponent);
        widget = fixture.componentInstance;
        element = fixture.nativeElement;
        authService = fixture.debugElement.injector.get(AuthenticationService);
        siteService = fixture.debugElement.injector.get(SitesService);
        spyOn(siteService, 'getSites').and.returnValue(of({ list: { entries: [] } }));
        spyOn(widget, 'isLoggedIn').and.callFake(() => {
            return isLogged;
        });
    }));

    afterEach(() => {
        fixture.destroy();
    });

    it('should be able to create the widget', () => {
        expect(widget).not.toBeNull();
    });

    describe('When is not logged in', () => {

        beforeEach(async(() => {
            fixture.detectChanges();
            isLogged = false;
        }));

        it('should show the login form', () => {
            expect(element.querySelector('#attach-file-login-panel')).not.toBeNull();
            expect(element.querySelector('#username')).not.toBeNull();
            expect(element.querySelector('#password')).not.toBeNull();
            expect(element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]')).not.toBeNull();
        });

        it('should be able to login', (done) => {
            spyOn(authService, 'login').and.returnValue(of({ type: 'type', ticket: 'ticket'}));
            isLogged = true;
            let loginButton: HTMLButtonElement = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]');
            let usernameInput: HTMLInputElement = element.querySelector('#username');
            let passwordInput: HTMLInputElement = element.querySelector('#password');
            usernameInput.value = 'fakse-user';
            passwordInput.value = 'fakse-user';
            usernameInput.dispatchEvent(new Event('input'));
            passwordInput.dispatchEvent(new Event('input'));
            loginButton.click();
            fixture.detectChanges();
            fixture.whenStable().then(() => {
                expect(element.querySelector('#attach-file-content-node')).not.toBeNull();
                loginButton = element.querySelector('button[data-automation-id="attach-file-dialog-actions-login"]');
                let chooseButton = element.querySelector('button[data-automation-id="attach-file-dialog-actions-choose"]');
                expect(loginButton).toBeNull();
                expect(chooseButton).not.toBeNull();
                done();
            });
        });

    });

    describe('When is logged in', () => {

        let contentNodePanel;

        beforeEach(async(() => {
            isLogged = true;
            fixture.detectChanges();
            contentNodePanel = fixture.debugElement.query(By.directive(ContentNodeSelectorPanelComponent));
        }));

        it('should show the content node selector', () => {
            expect(element.querySelector('#attach-file-content-node')).not.toBeNull();
            expect(element.querySelector('#username')).toBeNull();
            expect(element.querySelector('#password')).toBeNull();
//.........這裏部分代碼省略.........
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:101,代碼來源:attach-file-widget-dialog.component.spec.ts

示例10: describe

describe('Task Cloud Service', () => {

    let service: TaskCloudService;
    let alfrescoApiMock: AlfrescoApiServiceMock;
    let identityUserService: IdentityUserService;

    function returnFakeTaskCompleteResults() {
        return {
            oauth2Auth: {
                callCustomApi : () => {
                    return Promise.resolve(taskCompleteCloudMock);
                }
            }
        };
    }

    function returnFakeTaskCompleteResultsError() {
        return {
            oauth2Auth: {
                callCustomApi : () => {
                    return Promise.reject(taskCompleteCloudMock);
                }
            }
        };
    }

    function returnFakeTaskDetailsResults() {
        return {
            oauth2Auth: {
                callCustomApi : () => {
                    return Promise.resolve(fakeTaskDetailsCloud);
                }
            }
        };
    }

    setupTestBed({
        imports: [
            CoreModule.forRoot()
        ],
        providers: [ IdentityUserService ]
    });

    beforeEach(async(() => {
        alfrescoApiMock = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService() );
        identityUserService = TestBed.get(IdentityUserService);
        spyOn(identityUserService, 'getCurrentUserInfo').and.returnValue(cloudMockUser);
        service = new TaskCloudService(alfrescoApiMock,
                                           new AppConfigService(null),
                                           new LogService(new AppConfigService(null)),
                                           identityUserService);

    }));

    it('should complete a task', (done) => {
        const appName = 'simple-app';
        const taskId = '68d54a8f';
        spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnFakeTaskCompleteResults);
        service.completeTask(appName, taskId).subscribe((res: any) => {
            expect(res).toBeDefined();
            expect(res).not.toBeNull();
            expect(res.entry.appName).toBe('simple-app');
            expect(res.entry.id).toBe('68d54a8f');
            done();
        });
    });

    it('should not complete a task', (done) => {
        spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnFakeTaskCompleteResultsError);
        const appName = 'simple-app';
        const taskId = '68d54a8f';

        service.completeTask(appName, taskId).toPromise().then( (res: any) => {
        }, (error) => {
            expect(error).toBeDefined();
            done();
        });
    });

    it('should canCompleteTask', () => {
        const canCompleteTaskResult = service.canCompleteTask(taskDetailsCloudMock);
        expect(canCompleteTaskResult).toBeTruthy();
    });

    it('should return the task details when claiming a task', (done) => {
        const appName = 'taskp-app';
        const assignee = 'user12';
        const taskId = '68d54a8f';
        spyOn(alfrescoApiMock, 'getInstance').and.callFake(returnFakeTaskDetailsResults);
        service.claimTask(appName, taskId, assignee).subscribe((res: any) => {
            expect(res).toBeDefined();
            expect(res).not.toBeNull();
            expect(res.appName).toBe('task-app');
            expect(res.id).toBe('68d54a8f');
            done();
        });
    });

    it('should throw error if appName is not defined when claiming a task', (done) => {
        const appName = null;
//.........這裏部分代碼省略.........
開發者ID:Alfresco,項目名稱:alfresco-ng2-components,代碼行數:101,代碼來源:task-cloud.service.spec.ts


注:本文中的@alfresco/adf-core.CoreModule類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。