本文整理汇总了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();
});
});
示例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();
});
示例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');
});