当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript adf-core.setupTestBed函数代码示例

本文整理汇总了TypeScript中@alfresco/adf-core.setupTestBed函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setupTestBed函数的具体用法?TypeScript setupTestBed怎么用?TypeScript setupTestBed使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setupTestBed函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: describe

describe('Task List: Custom EmptyTemplateComponent', () => {
    let fixture: ComponentFixture<EmptyTemplateComponent>;
    let translateService: TranslateService;
    let taskListService: TaskListService;

    setupTestBed({
        imports: [ProcessTestingModule, TaskListModule, DataTableModule],
        declarations: [EmptyTemplateComponent]
    });

    beforeEach(() => {
        translateService = TestBed.get(TranslateService);
        taskListService = TestBed.get(TaskListService);
        spyOn(translateService, 'get').and.callFake((key) => {
            return of(key);
        });
        spyOn(taskListService, 'findTasksByState').and.returnValue(of(fakeEmptyTask));
        fixture = TestBed.createComponent(EmptyTemplateComponent);
        fixture.detectChanges();
    });

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

    it('should render the custom template', (done) => {
        fixture.detectChanges();
        fixture.whenStable().then(() => {
            expect(fixture.debugElement.query(By.css('#custom-id'))).not.toBeNull();
            expect(fixture.debugElement.query(By.css('.adf-empty-content'))).toBeNull();
            done();
        });
    });
});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:34,代码来源:task-list.component.spec.ts

示例2: describe

describe('Custom CustomEmptyAppListTemplateComponent', () => {
    let fixture: ComponentFixture<CustomEmptyAppListTemplateComponent>;

    setupTestBed({
        imports: [ProcessTestingModule],
        declarations: [CustomEmptyAppListTemplateComponent],
        schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
    });

    beforeEach(() => {
        fixture = TestBed.createComponent(CustomEmptyAppListTemplateComponent);
    });

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

    it('should render the custom no-apps template', async(() => {
        fixture.detectChanges();
        fixture.whenStable().then(() => {
            let title: any = fixture.debugElement.queryAll(By.css('#custom-id'));
            expect(title.length).toBe(1);
            expect(title[0].nativeElement.innerText).toBe('No Apps');
        });
    }));
});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:26,代码来源:apps-list.component.spec.ts

示例3: describe

    describe('Creating an empty custom template - EmptyTemplateComponent', () => {
        let fixtureEmpty: ComponentFixture<EmptyTemplateComponent>;

        setupTestBed({
            imports: [ProcessServiceCloudTestingModule, TaskListCloudModule],
            declarations: [EmptyTemplateComponent],
            schemas: [CUSTOM_ELEMENTS_SCHEMA]
        });

        beforeEach(() => {
            fixtureEmpty = TestBed.createComponent(EmptyTemplateComponent);
            fixtureEmpty.detectChanges();
        });

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

        it('should render the custom template', async(() => {
            fixtureEmpty.whenStable().then(() => {
                fixtureEmpty.detectChanges();
                expect(fixtureEmpty.debugElement.query(By.css('#custom-id'))).not.toBeNull();
                expect(fixtureEmpty.debugElement.query(By.css('.adf-empty-content'))).toBeNull();
            });
        }));
    });
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:26,代码来源:task-list-cloud.component.spec.ts

示例4: describe

describe('Process List: Custom EmptyTemplateComponent', () => {
    let fixture: ComponentFixture<EmptyTemplateComponent>;
    let processService: ProcessService;

    setupTestBed({
        imports: [ProcessTestingModule, ProcessListModule, DataTableModule],
        declarations: [EmptyTemplateComponent]
    });

    beforeEach(() => {
        fixture = TestBed.createComponent(EmptyTemplateComponent);
        processService = TestBed.get(ProcessService);
        spyOn(processService, 'getProcessInstances').and.returnValue(of(fakeProcessInstancesEmpty));
        fixture.detectChanges();
    });

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

    it('should render the custom template', (done) => {
        fixture.whenStable().then(() => {
            fixture.detectChanges();
            let title = fixture.debugElement.query(By.css('#custom-id'));
            expect(title).not.toBeNull();
            expect(title.nativeElement.innerText).toBe('No Process Instance');
            expect(fixture.debugElement.query(By.css('.adf-empty-content'))).toBeNull();
            done();
        });
    });
});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:31,代码来源:process-list.component.spec.ts

示例5: describe

describe('Custom CustomEmptyAppListCloudTemplateComponent', () => {
    let fixture: ComponentFixture<CustomEmptyAppListCloudTemplateComponent>;

    setupTestBed({
        imports: [ProcessServiceCloudTestingModule],
        declarations: [CustomEmptyAppListCloudTemplateComponent],
        schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
    });

    beforeEach(() => {
        fixture = TestBed.createComponent(CustomEmptyAppListCloudTemplateComponent);
    });

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

    it('should render the custom empty template', async(() => {
        fixture.detectChanges();
        fixture.whenStable().then(() => {
            const title: any =  fixture.nativeElement.querySelector('#custom-id');
            expect(title.innerText).toBe('No Apps Found');
        });
    }));
});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:25,代码来源:app-list-cloud.component.spec.ts

示例6: describe

describe('TagService', () => {

    let service: TagService;

    setupTestBed({
        imports: [ContentTestingModule]
    });

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

    beforeEach(() => {
        jasmine.Ajax.install();
    });

    afterEach(() => {
        jasmine.Ajax.uninstall();
    });

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

        it('getTagsByNodeId catch errors call', (done) => {
            service.getTagsByNodeId('fake-node-id').subscribe(() => {
            }, () => {
                done();
            });

            jasmine.Ajax.requests.mostRecent().respondWith({
                status: 403
            });
        });

        it('delete tag should trigger a refresh event', (done) => {
            service.refresh.subscribe(() => {
                done();
            });

            service.removeTag('fake-node-id', 'fake-tag');

            jasmine.Ajax.requests.mostRecent().respondWith({
                status: 200
            });
        });

        it('add tag should trigger a refresh event', (done) => {
            service.refresh.subscribe(() => {
                done();
            });

            service.addTag('fake-node-id', 'fake-tag');

            jasmine.Ajax.requests.mostRecent().respondWith({
                status: 200
            });
        });
    });

});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:59,代码来源:tag.service.spec.ts

示例7: describe

describe('AnalyticsService', () => {

    let service: AnalyticsService;

    setupTestBed({
        imports: [InsightsTestingModule]
    });

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

    beforeEach(() => {
        jasmine.Ajax.install();
    });

    afterEach(() => {
        jasmine.Ajax.uninstall();
    });

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

        it('should return the report list by appId', (done) => {
            service.getReportList(1).subscribe(
                (reportList) => {
                    expect(reportList).toBeDefined();
                    expect(reportList.length).toEqual(2);
                    expect(reportList[0].name).toEqual('Fake Report 1');
                    expect(reportList[1].name).toEqual('Fake Report 2');
                    done();
                }
            );

            jasmine.Ajax.requests.mostRecent().respondWith({
                'status': 200,
                contentType: 'application/json',
                responseText: JSON.stringify(fakeReportList)
            });
        });

        it('should return the report by report name', (done) => {
            service.getReportByName('Fake Report 2').subscribe(
                (report) => {
                    expect(report).toBeDefined();
                    expect(report).not.toBeNull();
                    expect(report.id).toEqual('2');
                    done();
                }
            );

            jasmine.Ajax.requests.mostRecent().respondWith({
                'status': 200,
                contentType: 'application/json',
                responseText: JSON.stringify(fakeReportList)
            });
        });
    });
});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:58,代码来源:analytics.service.spec.ts

示例8: describe

describe('ContentColumn', () => {

    let documentList: DocumentListComponent;
    let columnList: ContentColumnListComponent;
    let logService: LogService;

    setupTestBed({
        imports: [ContentTestingModule],
        schemas: [CUSTOM_ELEMENTS_SCHEMA]
    });

    beforeEach(() => {
        documentList = (TestBed.createComponent(DocumentListComponent).componentInstance as DocumentListComponent);
        logService = TestBed.get(LogService);
        columnList = new ContentColumnListComponent(documentList, logService);

        documentList.ngOnInit();
    });

    it('should register model within parent column list', () => {
        spyOn(columnList, 'registerColumn').and.callThrough();

        let column = new ContentColumnComponent(columnList, logService);
        column.ngAfterContentInit();

        expect(columnList.registerColumn).toHaveBeenCalled();

        let columns = documentList.data.getColumns();
        expect(columns.length).toBe(1);
        expect(columns[0]).toBe(column);
    });

    it('should setup screen reader title for thumbnail column', () => {
        let column = new ContentColumnComponent(columnList, logService);
        column.key = '$thumbnail';
        column.ngOnInit();

        expect(column.srTitle).toBe('Thumbnail');
    });

    it('should register on init', () => {
        let column = new ContentColumnComponent(columnList, logService);
        spyOn(column, 'register').and.callThrough();

        column.ngAfterContentInit();
        expect(column.register).toHaveBeenCalled();
    });

    it('should require action list to register action with', () => {
        let column = new ContentColumnComponent(columnList, logService);
        expect(column.register()).toBeTruthy();

        column = new ContentColumnComponent(null, logService);
        expect(column.register()).toBeFalsy();
    });

});
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:57,代码来源:content-column.component.spec.ts


注:本文中的@alfresco/adf-core.setupTestBed函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。