本文整理匯總了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' });
});