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


TypeScript sessions.component.SessionsComponent類代碼示例

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


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

示例1: describe

describe('Component Tests', () => {
    let sessions: Session[];
    let fixture: ComponentFixture<SessionsComponent>;
    let comp: SessionsComponent;

    describe('SessionsComponent', function() {
        beforeEach(() => {
            sessions = [new Session('xxxxxx==', new Date(2015, 10, 15), '0:0:0:0:0:0:0:1', 'Mozilla/5.0')];

            fixture = TestBed.configureTestingModule({
                imports: [TrebolTestModule],
                declarations: [SessionsComponent]
            })
                .overrideTemplate(SessionsComponent, '')
                .createComponent(SessionsComponent);
            comp = fixture.componentInstance;
        });

        it('should define its initial state', inject(
            [AccountService, SessionsService],
            fakeAsync((mockAccountService: MockAccountService, service: SessionsService) => {
                mockAccountService.spy('identity').and.returnValue(
                    Promise.resolve({
                        id: 'fuzzer'
                    })
                );
                spyOn(service, 'findAll').and.returnValue(of(sessions));

                comp.ngOnInit();
                tick();

                expect(mockAccountService.identitySpy).toHaveBeenCalled();
                expect(service.findAll).toHaveBeenCalled();
                expect(comp.success).toBeUndefined();
                expect(comp.error).toBeUndefined();
                expect(comp.account).toEqual({
                    id: 'fuzzer'
                });
                expect(comp.sessions).toEqual(sessions);
            })
        ));

        it('should call delete on Sessions to invalidate a session', inject(
            [AccountService, SessionsService],
            fakeAsync((mockAccountService: MockAccountService, service: SessionsService) => {
                mockAccountService.spy('identity').and.returnValue(
                    Promise.resolve({
                        id: 'fuzzer'
                    })
                );
                spyOn(service, 'findAll').and.returnValue(of(sessions));
                spyOn(service, 'delete').and.returnValue(of({}));

                comp.ngOnInit();
                comp.invalidate('xyz');
                tick();

                expect(service.delete).toHaveBeenCalledWith('xyz');
            })
        ));

        it('should call delete on Sessions and notify of error', inject(
            [AccountService, SessionsService],
            fakeAsync((mockAccountService: MockAccountService, service: SessionsService) => {
                mockAccountService.spy('identity').and.returnValue(
                    Promise.resolve({
                        id: 'fuzzer'
                    })
                );
                spyOn(service, 'findAll').and.returnValue(of(sessions));
                spyOn(service, 'delete').and.returnValue(
                    of({
                        status: 400
                    })
                );

                comp.ngOnInit();
                comp.invalidate('xyz');
                tick();

                expect(comp.success).toBeNull();
                expect(comp.error).toBe('ERROR');
            })
        ));

        it('should call notify of success upon session invalidation', inject(
            [AccountService, SessionsService],
            fakeAsync((mockAccountService: MockAccountService, service: SessionsService) => {
                mockAccountService.spy('identity').and.returnValue(
                    Promise.resolve({
                        id: 'fuzzer'
                    })
                );
                spyOn(service, 'findAll').and.returnValue(of(sessions));
                spyOn(service, 'delete').and.returnValue(
                    of({
                        status: 200
                    })
                );

//.........這裏部分代碼省略.........
開發者ID:Danils123,項目名稱:Prueba-azure,代碼行數:101,代碼來源:sessions.component.spec.ts

示例2: fakeAsync

            fakeAsync((mockAccountService: MockAccountService, service: SessionsService) => {
                mockAccountService.spy('identity').and.returnValue(
                    Promise.resolve({
                        id: 'fuzzer'
                    })
                );
                spyOn(service, 'findAll').and.returnValue(of(sessions));
                spyOn(service, 'delete').and.returnValue(of({}));

                comp.ngOnInit();
                comp.invalidate('xyz');
                tick();

                expect(service.delete).toHaveBeenCalledWith('xyz');
            })
開發者ID:Danils123,項目名稱:Prueba-azure,代碼行數:15,代碼來源:sessions.component.spec.ts

示例3: fakeAsync

                fakeAsync((mockPrincipal: MockPrincipal, service: SessionsService) => {
                    mockPrincipal.spy('identity').and.returnValue(
                        Promise.resolve({
                            id: 'fuzzer'
                        })
                    );
                    spyOn(service, 'findAll').and.returnValue(Observable.of(sessions));
                    spyOn(service, 'delete').and.returnValue(
                        Observable.of({
                            status: 400
                        })
                    );

                    comp.ngOnInit();
                    comp.invalidate('xyz');
                    tick();

                    expect(comp.success).toBeNull();
                    expect(comp.error).toBe('ERROR');
                })
開發者ID:mantonaci,項目名稱:jhipster5java10,代碼行數:20,代碼來源:sessions.component.spec.ts


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