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


TypeScript password-reset-init.component.PasswordResetInitComponent類代碼示例

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


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

示例1: beforeEach

 beforeEach(() => {
     fixture = TestBed.configureTestingModule({
         imports: [BookstoreTestModule],
         declarations: [PasswordResetInitComponent],
         providers: [
             {
                 provide: Renderer,
                 useValue: {
                     invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {}
                 }
             },
             {
                 provide: ElementRef,
                 useValue: new ElementRef(null)
             }
         ]
     })
         .overrideTemplate(PasswordResetInitComponent, '')
         .createComponent(PasswordResetInitComponent);
     comp = fixture.componentInstance;
     comp.ngOnInit();
 });
開發者ID:Doha2012,項目名稱:tutorials,代碼行數:22,代碼來源:password-reset-init.component.spec.ts

示例2: describe

    describe('PasswordResetInitComponent', () => {
        let fixture: ComponentFixture<PasswordResetInitComponent>;
        let comp: PasswordResetInitComponent;

        beforeEach(() => {
            fixture = TestBed.configureTestingModule({
                imports: [Jhipster5Java10TestModule],
                declarations: [PasswordResetInitComponent],
                providers: [
                    PasswordResetInitService,
                    {
                        provide: Renderer,
                        useValue: {
                            invokeElementMethod(renderElement: any, methodName: string, args?: any[]) {}
                        }
                    },
                    {
                        provide: ElementRef,
                        useValue: new ElementRef(null)
                    }
                ]
            })
                .overrideTemplate(PasswordResetInitComponent, '')
                .createComponent(PasswordResetInitComponent);
            comp = fixture.componentInstance;
            comp.ngOnInit();
        });

        it('should define its initial state', () => {
            expect(comp.success).toBeUndefined();
            expect(comp.error).toBeUndefined();
            expect(comp.errorEmailNotExists).toBeUndefined();
            expect(comp.resetAccount).toEqual({});
        });

        it(
            'sets focus after the view has been initialized',
            inject([ElementRef], (elementRef: ElementRef) => {
                const element = fixture.nativeElement;
                const node = {
                    focus() {}
                };

                elementRef.nativeElement = element;
                spyOn(element, 'querySelector').and.returnValue(node);
                spyOn(node, 'focus');

                comp.ngAfterViewInit();

                expect(element.querySelector).toHaveBeenCalledWith('#email');
                expect(node.focus).toHaveBeenCalled();
            })
        );

        it(
            'notifies of success upon successful requestReset',
            inject([PasswordResetInitService], (service: PasswordResetInitService) => {
                spyOn(service, 'save').and.returnValue(Observable.of({}));
                comp.resetAccount.email = 'user@domain.com';

                comp.requestReset();

                expect(service.save).toHaveBeenCalledWith('user@domain.com');
                expect(comp.success).toEqual('OK');
                expect(comp.error).toBeNull();
                expect(comp.errorEmailNotExists).toBeNull();
            })
        );

        it(
            'notifies of unknown email upon email address not registered/400',
            inject([PasswordResetInitService], (service: PasswordResetInitService) => {
                spyOn(service, 'save').and.returnValue(
                    Observable.throw({
                        status: 400,
                        error: { type: EMAIL_NOT_FOUND_TYPE }
                    })
                );
                comp.resetAccount.email = 'user@domain.com';

                comp.requestReset();

                expect(service.save).toHaveBeenCalledWith('user@domain.com');
                expect(comp.success).toBeNull();
                expect(comp.error).toBeNull();
                expect(comp.errorEmailNotExists).toEqual('ERROR');
            })
        );

        it(
            'notifies of error upon error response',
            inject([PasswordResetInitService], (service: PasswordResetInitService) => {
                spyOn(service, 'save').and.returnValue(
                    Observable.throw({
                        status: 503,
                        data: 'something else'
                    })
                );
                comp.resetAccount.email = 'user@domain.com';

//.........這裏部分代碼省略.........
開發者ID:mantonaci,項目名稱:jhipster5java10,代碼行數:101,代碼來源:password-reset-init.component.spec.ts

示例3: inject

            inject([PasswordResetInitService], (service: PasswordResetInitService) => {
                spyOn(service, 'save').and.returnValue(Observable.of({}));
                comp.resetAccount.email = 'user@domain.com';

                comp.requestReset();

                expect(service.save).toHaveBeenCalledWith('user@domain.com');
                expect(comp.success).toEqual('OK');
                expect(comp.error).toBeNull();
                expect(comp.errorEmailNotExists).toBeNull();
            })
開發者ID:mantonaci,項目名稱:jhipster5java10,代碼行數:11,代碼來源:password-reset-init.component.spec.ts

示例4: it

    it('notifies of success upon successful requestReset', inject([PasswordResetInitService], (service: PasswordResetInitService) => {
      spyOn(service, 'save').and.returnValue(of({}));
      comp.resetRequestForm.patchValue({
        email: 'user@domain.com'
      });

      comp.requestReset();

      expect(service.save).toHaveBeenCalledWith('user@domain.com');
      expect(comp.success).toEqual('OK');
      expect(comp.error).toBeNull();
      expect(comp.errorEmailNotExists).toBeNull();
    }));
開發者ID:jhipster,項目名稱:jhipster-sample-app-gradle,代碼行數:13,代碼來源:password-reset-init.component.spec.ts

示例5: spyOn

      (service: PasswordResetInitService) => {
        spyOn(service, 'save').and.returnValue(
          throwError({
            status: 400,
            error: { type: EMAIL_NOT_FOUND_TYPE }
          })
        );
        comp.resetRequestForm.patchValue({
          email: 'user@domain.com'
        });
        comp.requestReset();

        expect(service.save).toHaveBeenCalledWith('user@domain.com');
        expect(comp.success).toBeNull();
        expect(comp.error).toBeNull();
        expect(comp.errorEmailNotExists).toEqual('ERROR');
      }
開發者ID:jhipster,項目名稱:jhipster-sample-app-gradle,代碼行數:17,代碼來源:password-reset-init.component.spec.ts


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