本文整理汇总了TypeScript中app/admin/health/health.component.JhiHealthCheckComponent类的典型用法代码示例。如果您正苦于以下问题:TypeScript component.JhiHealthCheckComponent类的具体用法?TypeScript component.JhiHealthCheckComponent怎么用?TypeScript component.JhiHealthCheckComponent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了component.JhiHealthCheckComponent类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('JhiHealthCheckComponent', () => {
let comp: JhiHealthCheckComponent;
let fixture: ComponentFixture<JhiHealthCheckComponent>;
let service: JhiHealthService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [JhipsterSampleApplicationTestModule],
declarations: [JhiHealthCheckComponent]
})
.overrideTemplate(JhiHealthCheckComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(JhiHealthCheckComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(JhiHealthService);
});
describe('baseName and subSystemName', () => {
it('should return the basename when it has no sub system', () => {
expect(comp.baseName('base')).toBe('base');
});
it('should return the basename when it has sub systems', () => {
expect(comp.baseName('base.subsystem.system')).toBe('base');
});
it('should return the sub system name', () => {
expect(comp.subSystemName('subsystem')).toBe('');
});
it('should return the subsystem when it has multiple keys', () => {
expect(comp.subSystemName('subsystem.subsystem.system')).toBe(' - subsystem.system');
});
});
describe('transformHealthData', () => {
it('should flatten empty health data', () => {
const data = {};
const expected = [];
expect(service.transformHealthData(data)).toEqual(expected);
});
it('should flatten health data with no subsystems', () => {
const data = {
details: {
status: 'UP',
db: {
status: 'UP',
database: 'H2',
hello: '1'
},
mail: {
status: 'UP',
error: 'mail.a.b.c'
}
}
};
const expected = [
{
name: 'db',
status: 'UP',
details: {
database: 'H2',
hello: '1'
}
},
{
name: 'mail',
error: 'mail.a.b.c',
status: 'UP'
}
];
expect(service.transformHealthData(data)).toEqual(expected);
});
it('should flatten health data with subsystems at level 1, main system has no additional information', () => {
const data = {
details: {
status: 'UP',
db: {
status: 'UP',
database: 'H2',
hello: '1'
},
mail: {
status: 'UP',
error: 'mail.a.b.c'
},
system: {
status: 'DOWN',
subsystem1: {
status: 'UP',
property1: 'system.subsystem1.property1'
},
subsystem2: {
status: 'DOWN',
error: 'system.subsystem1.error',
//.........这里部分代码省略.........
示例2: describe
describe('JhiHealthCheckComponent', () => {
let comp: JhiHealthCheckComponent;
let fixture: ComponentFixture<JhiHealthCheckComponent>;
let service: JhiHealthService;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [BackendJhipsterTestModule],
declarations: [JhiHealthCheckComponent]
})
.overrideTemplate(JhiHealthCheckComponent, '')
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(JhiHealthCheckComponent);
comp = fixture.componentInstance;
service = fixture.debugElement.injector.get(JhiHealthService);
});
describe('baseName and subSystemName', () => {
it('should return the basename when it has no sub system', () => {
expect(comp.baseName('base')).toBe('base');
});
it('should return the basename when it has sub systems', () => {
expect(comp.baseName('base.subsystem.system')).toBe('base');
});
it('should return the sub system name', () => {
expect(comp.subSystemName('subsystem')).toBe('');
});
it('should return the subsystem when it has multiple keys', () => {
expect(comp.subSystemName('subsystem.subsystem.system')).toBe(' - subsystem.system');
});
});
describe('transformHealthData', () => {
it('should flatten empty health data', () => {
const data = {};
const expected = [];
expect(service.transformHealthData(data)).toEqual(expected);
});
});
it('should flatten health data with no subsystems', () => {
const data = {
details: {
status: 'UP',
db: {
status: 'UP',
database: 'H2',
hello: '1'
},
mail: {
status: 'UP',
error: 'mail.a.b.c'
}
}
};
const expected = [
{
name: 'db',
status: 'UP',
details: {
database: 'H2',
hello: '1'
}
},
{
name: 'mail',
error: 'mail.a.b.c',
status: 'UP'
}
];
expect(service.transformHealthData(data)).toEqual(expected);
});
it('should flatten health data with subsystems at level 1, main system has no additional information', () => {
const data = {
details: {
status: 'UP',
db: {
status: 'UP',
database: 'H2',
hello: '1'
},
mail: {
status: 'UP',
error: 'mail.a.b.c'
},
system: {
status: 'DOWN',
subsystem1: {
status: 'UP',
property1: 'system.subsystem1.property1'
},
subsystem2: {
status: 'DOWN',
//.........这里部分代码省略.........
示例3: it
it('should handle a 503 on refreshing health data', () => {
// GIVEN
spyOn(service, 'checkHealth').and.returnValue(throwError(new HttpErrorResponse({ status: 503, error: 'Mail down' })));
spyOn(service, 'transformHealthData').and.returnValue(of({ health: 'down' }));
// WHEN
comp.refresh();
// THEN
expect(service.checkHealth).toHaveBeenCalled();
expect(service.transformHealthData).toHaveBeenCalled();
expect(comp.healthData.value).toEqual({ health: 'down' });
});