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


TypeScript settings.component.SettingsComponent类代码示例

本文整理汇总了TypeScript中app/account/settings/settings.component.SettingsComponent的典型用法代码示例。如果您正苦于以下问题:TypeScript component.SettingsComponent类的具体用法?TypeScript component.SettingsComponent怎么用?TypeScript component.SettingsComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: describe

  describe('SettingsComponent', () => {
    let comp: SettingsComponent;
    let fixture: ComponentFixture<SettingsComponent>;
    let mockAuth: any;

    beforeEach(async(() => {
      TestBed.configureTestingModule({
        imports: [JhipsterSampleApplicationTestModule],
        declarations: [SettingsComponent],
        providers: [FormBuilder]
      })
        .overrideTemplate(SettingsComponent, '')
        .compileComponents();
    }));

    beforeEach(() => {
      fixture = TestBed.createComponent(SettingsComponent);
      comp = fixture.componentInstance;
      mockAuth = fixture.debugElement.injector.get(AccountService);
    });

    it('should send the current identity upon save', () => {
      // GIVEN
      const accountValues = {
        firstName: 'John',
        lastName: 'Doe',

        activated: true,
        email: 'john.doe@mail.com',
        langKey: 'en',
        login: 'john'
      };
      mockAuth.setIdentityResponse(accountValues);

      // WHEN
      comp.updateForm(accountValues);
      comp.save();

      // THEN
      expect(mockAuth.identitySpy).toHaveBeenCalled();
      expect(mockAuth.saveSpy).toHaveBeenCalledWith(accountValues);
      expect(comp.settingsForm.value).toEqual(accountValues);
    });

    it('should notify of success upon successful save', () => {
      // GIVEN
      const accountValues = {
        firstName: 'John',
        lastName: 'Doe'
      };
      comp.settingsForm.patchValue({
        firstName: 'John',
        lastName: 'Doe'
      });
      mockAuth.setIdentityResponse(accountValues);
      // WHEN
      comp.save();

      // THEN
      expect(comp.error).toBeNull();
      expect(comp.success).toBe('OK');
    });

    it('should notify of error upon failed save', () => {
      // GIVEN
      mockAuth.saveSpy.and.returnValue(throwError('ERROR'));
      // WHEN
      comp.save();

      // THEN
      expect(comp.error).toEqual('ERROR');
      expect(comp.success).toBeNull();
    });
  });
开发者ID:jhipster,项目名称:jhipster-sample-app,代码行数:74,代码来源:settings.component.spec.ts

示例2: it

    it('should notify of error upon failed save', () => {
      // GIVEN
      mockAuth.saveSpy.and.returnValue(throwError('ERROR'));
      // WHEN
      comp.save();

      // THEN
      expect(comp.error).toEqual('ERROR');
      expect(comp.success).toBeNull();
    });
开发者ID:jhipster,项目名称:jhipster-sample-app,代码行数:10,代码来源:settings.component.spec.ts

示例3: it

        it('should notify of success upon successful save', () => {
            // GIVEN
            const accountValues = {
                firstName: 'John',
                lastName: 'Doe'
            };
            mockPrincipal.setResponse(accountValues);

            // WHEN
            comp.save();

            // THEN
            expect(comp.error).toBeNull();
            expect(comp.success).toBe('OK');
        });
开发者ID:EugeneGoroschenya,项目名称:jhipster-sample-application,代码行数:15,代码来源:settings.component.spec.ts


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