本文整理匯總了TypeScript中ngx-bootstrap/popover.PopoverModule類的典型用法代碼示例。如果您正苦於以下問題:TypeScript PopoverModule類的具體用法?TypeScript PopoverModule怎麽用?TypeScript PopoverModule使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了PopoverModule類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: describe
describe('HealthComponent', () => {
let component: HealthComponent;
let fixture: ComponentFixture<HealthComponent>;
configureTestBed({
providers: [DashboardService],
imports: [SharedModule, HttpClientTestingModule, PopoverModule.forRoot()],
declarations: [
HealthComponent,
MonSummaryPipe,
OsdSummaryPipe,
MdsSummaryPipe,
MgrSummaryPipe,
PgStatusStylePipe,
LogColorPipe,
PgStatusPipe
],
schemas: [NO_ERRORS_SCHEMA]
});
beforeEach(() => {
fixture = TestBed.createComponent(HealthComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
示例2: async
async(() => {
TestBed.configureTestingModule({
imports: [PopoverModule.forRoot(), SharedModule],
declarations: [NotificationsComponent],
providers: [{ provide: NotificationService, useValue: fakeService }]
}).compileComponents();
})
示例3: describe
describe('SelectBadgesComponent', () => {
let component: SelectBadgesComponent;
let fixture: ComponentFixture<SelectBadgesComponent>;
configureTestBed({
declarations: [SelectBadgesComponent, SelectComponent],
imports: [PopoverModule.forRoot(), TooltipModule, ReactiveFormsModule],
providers: i18nProviders
});
beforeEach(() => {
fixture = TestBed.createComponent(SelectBadgesComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should reflect the attributes into CdSelect', () => {
const data = ['a', 'b'];
const options = [
{ name: 'option1', description: '', selected: false, enabled: true },
{ name: 'option2', description: '', selected: false, enabled: true }
];
const i18n = TestBed.get(I18n);
const messages = new SelectMessages({ empty: 'foo bar' }, i18n);
const selectionLimit = 2;
const customBadges = true;
const customBadgeValidators = [Validators.required];
component.data = data;
component.options = options;
component.messages = messages;
component.selectionLimit = selectionLimit;
component.customBadges = customBadges;
component.customBadgeValidators = customBadgeValidators;
fixture.detectChanges();
expect(component.cdSelect.data).toEqual(data);
expect(component.cdSelect.options).toEqual(options);
expect(component.cdSelect.messages).toEqual(messages);
expect(component.cdSelect.selectionLimit).toEqual(selectionLimit);
expect(component.cdSelect.customBadges).toEqual(customBadges);
expect(component.cdSelect.customBadgeValidators).toEqual(customBadgeValidators);
});
});
示例4: async
async(() => {
TestBed.configureTestingModule({
imports: [
SharedModule,
RouterTestingModule,
HttpClientTestingModule,
PopoverModule.forRoot()
],
declarations: [
NavigationComponent,
NotificationsComponent,
LogoutComponent,
TaskManagerComponent
],
providers: [{ provide: NotificationService, useValue: fakeService }]
}).compileComponents();
})
示例5: describe
describe('NotificationsComponent', () => {
let component: NotificationsComponent;
let fixture: ComponentFixture<NotificationsComponent>;
configureTestBed({
imports: [PopoverModule.forRoot(), SharedModule, ToastModule.forRoot()],
declarations: [NotificationsComponent]
});
beforeEach(() => {
fixture = TestBed.createComponent(NotificationsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
示例6: describe
describe('HealthComponent', () => {
let component: HealthComponent;
let fixture: ComponentFixture<HealthComponent>;
let getHealthSpy;
const healthPayload = {
health: { status: 'HEALTH_OK' },
mon_status: { monmap: { mons: [] }, quorum: [] },
osd_map: { osds: [] },
mgr_map: { standbys: [] },
hosts: 0,
rgw: 0,
fs_map: { filesystems: [] },
iscsi_daemons: 0,
client_perf: {},
scrub_status: 'Inactive',
pools: [],
df: { stats: { total_objects: 0 } },
pg_info: {}
};
configureTestBed({
imports: [SharedModule, HttpClientTestingModule, PopoverModule.forRoot()],
declarations: [
HealthComponent,
MonSummaryPipe,
OsdSummaryPipe,
MdsSummaryPipe,
MgrSummaryPipe,
PgStatusStylePipe,
LogColorPipe,
PgStatusPipe
],
schemas: [NO_ERRORS_SCHEMA]
});
beforeEach(() => {
fixture = TestBed.createComponent(HealthComponent);
component = fixture.componentInstance;
getHealthSpy = spyOn(TestBed.get(DashboardService), 'getHealth');
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should render all info groups and all info cards', () => {
getHealthSpy.and.returnValue(of(healthPayload));
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(3);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(18);
});
it('should render all except "Status" group and cards', () => {
const payload = _.cloneDeep(healthPayload);
payload.health.status = '';
payload.mon_status = null;
payload.osd_map = null;
payload.mgr_map = null;
payload.hosts = null;
payload.rgw = null;
payload.fs_map = null;
payload.iscsi_daemons = null;
getHealthSpy.and.returnValue(of(payload));
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(2);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(10);
});
it('should render all except "Performance" group and cards', () => {
const payload = _.cloneDeep(healthPayload);
payload.scrub_status = '';
payload.client_perf = null;
getHealthSpy.and.returnValue(of(payload));
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(2);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(13);
});
it('should render all except "Capacity" group and cards', () => {
const payload = _.cloneDeep(healthPayload);
payload.pools = null;
payload.df = null;
payload.pg_info = null;
getHealthSpy.and.returnValue(of(payload));
fixture.detectChanges();
//.........這裏部分代碼省略.........
示例7: describe
describe('HealthComponent', () => {
let component: HealthComponent;
let fixture: ComponentFixture<HealthComponent>;
let getHealthSpy;
const healthPayload = {
health: { status: 'HEALTH_OK' },
mon_status: { monmap: { mons: [] }, quorum: [] },
osd_map: { osds: [] },
mgr_map: { standbys: [] },
hosts: 0,
rgw: 0,
fs_map: { filesystems: [] },
iscsi_daemons: 0,
client_perf: {},
scrub_status: 'Inactive',
pools: [],
df: { stats: { total_objects: 0 } },
pg_info: {}
};
const fakeAuthStorageService = {
getPermissions: () => {
return new Permissions({ log: ['read'] });
}
};
configureTestBed({
imports: [SharedModule, HttpClientTestingModule, PopoverModule.forRoot()],
declarations: [
HealthComponent,
MonSummaryPipe,
OsdSummaryPipe,
MdsSummaryPipe,
MgrSummaryPipe,
PgStatusStylePipe,
PgStatusPipe
],
schemas: [NO_ERRORS_SCHEMA],
providers: [i18nProviders, { provide: AuthStorageService, useValue: fakeAuthStorageService }]
});
beforeEach(() => {
fixture = TestBed.createComponent(HealthComponent);
component = fixture.componentInstance;
getHealthSpy = spyOn(TestBed.get(HealthService), 'getMinimalHealth');
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should render all info groups and all info cards', () => {
getHealthSpy.and.returnValue(of(healthPayload));
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(3);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(18);
});
it('should render all except "Status" group and cards', () => {
const payload = _.cloneDeep(healthPayload);
payload.health.status = '';
payload.mon_status = null;
payload.osd_map = null;
payload.mgr_map = null;
payload.hosts = null;
payload.rgw = null;
payload.fs_map = null;
payload.iscsi_daemons = null;
getHealthSpy.and.returnValue(of(payload));
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(2);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(10);
});
it('should render all except "Performance" group and cards', () => {
const payload = _.cloneDeep(healthPayload);
payload.scrub_status = '';
payload.client_perf = null;
getHealthSpy.and.returnValue(of(payload));
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(2);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(13);
});
it('should render all except "Capacity" group and cards', () => {
const payload = _.cloneDeep(healthPayload);
payload.pools = null;
//.........這裏部分代碼省略.........
示例8: describe
describe('ConfigOptionComponent', () => {
let component: ConfigOptionComponent;
let fixture: ComponentFixture<ConfigOptionComponent>;
let configurationService: ConfigurationService;
let oNames: Array<string>;
configureTestBed({
declarations: [ConfigOptionComponent, HelperComponent],
imports: [PopoverModule.forRoot(), ReactiveFormsModule, HttpClientTestingModule],
providers: [ConfigurationService]
});
beforeEach(() => {
fixture = TestBed.createComponent(ConfigOptionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
configurationService = TestBed.get(ConfigurationService);
const configOptions = [
{
name: 'osd_scrub_auto_repair_num_errors',
type: 'uint',
level: 'advanced',
desc: 'Maximum number of detected errors to automatically repair',
long_desc: '',
default: 5,
daemon_default: '',
tags: [],
services: [],
see_also: ['osd_scrub_auto_repair'],
min: '',
max: '',
can_update_at_runtime: true,
flags: []
},
{
name: 'osd_debug_deep_scrub_sleep',
type: 'float',
level: 'dev',
desc:
'Inject an expensive sleep during deep scrub IO to make it easier to induce preemption',
long_desc: '',
default: 0,
daemon_default: '',
tags: [],
services: [],
see_also: [],
min: '',
max: '',
can_update_at_runtime: true,
flags: []
},
{
name: 'osd_heartbeat_interval',
type: 'int',
level: 'advanced',
desc: 'Interval (in seconds) between peer pings',
long_desc: '',
default: 6,
daemon_default: '',
tags: [],
services: [],
see_also: [],
min: 1,
max: 86400,
can_update_at_runtime: true,
flags: [],
value: [
{
section: 'osd',
value: 6
}
]
},
{
name: 'bluestore_compression_algorithm',
type: 'str',
level: 'advanced',
desc: 'Default compression algorithm to use when writing object data',
long_desc:
'This controls the default compressor to use (if any) if the ' +
'per-pool property is not set. Note that zstd is *not* recommended for ' +
'bluestore due to high CPU overhead when compressing small amounts of data.',
default: 'snappy',
daemon_default: '',
tags: [],
services: [],
see_also: [],
enum_values: ['', 'snappy', 'zlib', 'zstd', 'lz4'],
min: '',
max: '',
can_update_at_runtime: true,
flags: ['runtime']
},
{
name: 'rbd_discard_on_zeroed_write_same',
type: 'bool',
level: 'advanced',
desc: 'discard data on zeroed write same instead of writing zero',
long_desc: '',
//.........這裏部分代碼省略.........
示例9: describe
describe('SelectComponent', () => {
let component: SelectComponent;
let fixture: ComponentFixture<SelectComponent>;
const selectOption = (filter: string) => {
component.filter.setValue(filter);
component.updateFilter();
component.selectOption();
};
configureTestBed({
declarations: [SelectComponent],
imports: [PopoverModule.forRoot(), TooltipModule, ReactiveFormsModule],
providers: i18nProviders
});
beforeEach(() => {
fixture = TestBed.createComponent(SelectComponent);
component = fixture.componentInstance;
fixture.detectChanges();
component.options = [
{ name: 'option1', description: '', selected: false },
{ name: 'option2', description: '', selected: false },
{ name: 'option3', description: '', selected: false }
];
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should add item', () => {
component.data = [];
component.triggerSelection(component.options[1]);
expect(component.data).toEqual(['option2']);
});
it('should update selected', () => {
component.data = ['option2'];
component.ngOnChanges();
expect(component.options[0].selected).toBe(false);
expect(component.options[1].selected).toBe(true);
});
it('should remove item', () => {
component.options.map((option) => {
option.selected = true;
return option;
});
component.data = ['option1', 'option2', 'option3'];
component.removeItem('option1');
expect(component.data).toEqual(['option2', 'option3']);
});
it('should not remove item that is not selected', () => {
component.options[0].selected = true;
component.data = ['option1'];
component.removeItem('option2');
expect(component.data).toEqual(['option1']);
});
describe('filter values', () => {
beforeEach(() => {
component.ngOnInit();
});
it('shows all options with no value set', () => {
expect(component.filteredOptions).toEqual(component.options);
});
it('shows one option that it filtered for', () => {
component.filter.setValue('2');
component.updateFilter();
expect(component.filteredOptions).toEqual([component.options[1]]);
});
it('shows all options after selecting something', () => {
component.filter.setValue('2');
component.updateFilter();
component.selectOption();
expect(component.filteredOptions).toEqual(component.options);
});
it('is not able to create by default with no value set', () => {
component.updateFilter();
expect(component.isCreatable()).toBeFalsy();
});
it('is not able to create by default with a value set', () => {
component.filter.setValue('2');
component.updateFilter();
expect(component.isCreatable()).toBeFalsy();
});
});
describe('automatically add selected options if not in options array', () => {
beforeEach(() => {
component.data = ['option1', 'option4'];
expect(component.options.length).toBe(3);
});
//.........這裏部分代碼省略.........
示例10: describe
describe('HealthComponent', () => {
let component: HealthComponent;
let fixture: ComponentFixture<HealthComponent>;
let getHealthSpy;
const healthPayload = {
health: { status: 'HEALTH_OK' },
mon_status: { monmap: { mons: [] }, quorum: [] },
osd_map: { osds: [] },
mgr_map: { standbys: [] },
hosts: 0,
rgw: 0,
fs_map: { filesystems: [] },
iscsi_daemons: 0,
client_perf: {},
scrub_status: 'Inactive',
pools: [],
df: { stats: { total_objects: 0 } },
pg_info: {}
};
const fakeAuthStorageService = {
getPermissions: () => {
return new Permissions({ log: ['read'] });
}
};
let fakeFeatureTogglesService;
configureTestBed({
imports: [SharedModule, HttpClientTestingModule, PopoverModule.forRoot()],
declarations: [
HealthComponent,
HealthPieComponent,
MonSummaryPipe,
OsdSummaryPipe,
MdsSummaryPipe,
MgrSummaryPipe
],
schemas: [NO_ERRORS_SCHEMA],
providers: [
i18nProviders,
{ provide: AuthStorageService, useValue: fakeAuthStorageService },
PgCategoryService,
RefreshIntervalService
]
});
beforeEach(() => {
fakeFeatureTogglesService = spyOn(TestBed.get(FeatureTogglesService), 'get').and.returnValue(
of({
rbd: true,
mirroring: true,
iscsi: true,
cephfs: true,
rgw: true
})
);
fixture = TestBed.createComponent(HealthComponent);
component = fixture.componentInstance;
getHealthSpy = spyOn(TestBed.get(HealthService), 'getMinimalHealth');
getHealthSpy.and.returnValue(of(healthPayload));
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should render all info groups and all info cards', () => {
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(3);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(18);
});
describe('features disabled', () => {
beforeEach(() => {
fakeFeatureTogglesService.and.returnValue(
of({
rbd: false,
mirroring: false,
iscsi: false,
cephfs: false,
rgw: false
})
);
fixture = TestBed.createComponent(HealthComponent);
component = fixture.componentInstance;
});
it('should not render cards related to disabled features', () => {
fixture.detectChanges();
const infoGroups = fixture.debugElement.nativeElement.querySelectorAll('cd-info-group');
expect(infoGroups.length).toBe(3);
const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
expect(infoCards.length).toBe(15);
});
});
//.........這裏部分代碼省略.........
示例11: describe
describe('TaskManagerComponent', () => {
let component: TaskManagerComponent;
let fixture: ComponentFixture<TaskManagerComponent>;
const tasks = {
executing: [],
finished: []
};
configureTestBed({
imports: [SharedModule, PopoverModule.forRoot(), HttpClientTestingModule, RouterTestingModule],
declarations: [TaskManagerComponent],
providers: [i18nProviders]
});
beforeEach(() => {
fixture = TestBed.createComponent(TaskManagerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
tasks.executing = [
new ExecutingTask('rbd/delete', {
pool_name: 'somePool',
image_name: 'someImage'
})
];
tasks.finished = [
new FinishedTask('rbd/copy', {
dest_pool_name: 'somePool',
dest_image_name: 'someImage'
}),
new FinishedTask('rbd/clone', {
child_pool_name: 'somePool',
child_image_name: 'someImage'
})
];
tasks.finished[1].success = false;
tasks.finished[1].exception = { code: 17 };
});
it('should create', () => {
expect(component).toBeTruthy();
});
it('should get executing message for task', () => {
component._handleTasks(tasks.executing, []);
expect(component.executingTasks.length).toBe(1);
expect(component.executingTasks[0].description).toBe(`Deleting RBD 'somePool/someImage'`);
});
it('should get finished message for successful task', () => {
component._handleTasks([], tasks.finished);
expect(component.finishedTasks.length).toBe(2);
expect(component.finishedTasks[0].description).toBe(`Copied RBD 'somePool/someImage'`);
expect(component.finishedTasks[0].errorMessage).toBe(undefined);
});
it('should get failed message for finished task', () => {
component._handleTasks([], tasks.finished);
expect(component.finishedTasks.length).toBe(2);
expect(component.finishedTasks[1].description).toBe(`Failed to clone RBD 'somePool/someImage'`);
expect(component.finishedTasks[1].errorMessage).toBe(
`Name is already used by RBD 'somePool/someImage'.`
);
});
it('should get an empty hour glass with only finished tasks', () => {
component._setIcon(0);
expect(component.icon).toBe('fa-hourglass-o');
});
it('should get a nearly empty hour glass with executing tasks', () => {
component._setIcon(10);
expect(component.icon).toBe('fa-hourglass-start');
});
});
示例12: describe
describe('NotificationsComponent', () => {
let component: NotificationsComponent;
let fixture: ComponentFixture<NotificationsComponent>;
configureTestBed({
imports: [
HttpClientTestingModule,
PopoverModule.forRoot(),
SharedModule,
ToastModule.forRoot()
],
declarations: [NotificationsComponent],
providers: i18nProviders
});
beforeEach(() => {
fixture = TestBed.createComponent(NotificationsComponent);
component = fixture.componentInstance;
});
it('should create', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
describe('prometheus alert handling', () => {
let prometheusAlertService: PrometheusAlertService;
let prometheusNotificationService: PrometheusNotificationService;
let prometheusAccessAllowed: boolean;
const expectPrometheusServicesToBeCalledTimes = (n: number) => {
expect(prometheusNotificationService.refresh).toHaveBeenCalledTimes(n);
expect(prometheusAlertService.refresh).toHaveBeenCalledTimes(n);
};
beforeEach(() => {
prometheusAccessAllowed = true;
spyOn(TestBed.get(AuthStorageService), 'getPermissions').and.callFake(() => ({
prometheus: { read: prometheusAccessAllowed }
}));
spyOn(TestBed.get(PrometheusService), 'ifAlertmanagerConfigured').and.callFake((fn) => fn());
prometheusAlertService = TestBed.get(PrometheusAlertService);
spyOn(prometheusAlertService, 'refresh').and.stub();
prometheusNotificationService = TestBed.get(PrometheusNotificationService);
spyOn(prometheusNotificationService, 'refresh').and.stub();
});
it('should not refresh prometheus services if not allowed', () => {
prometheusAccessAllowed = false;
fixture.detectChanges();
expectPrometheusServicesToBeCalledTimes(0);
});
it('should first refresh prometheus notifications and alerts during init', () => {
fixture.detectChanges();
expect(prometheusAlertService.refresh).toHaveBeenCalledTimes(1);
expectPrometheusServicesToBeCalledTimes(1);
});
it('should refresh prometheus services every 5s', fakeAsync(() => {
fixture.detectChanges();
expectPrometheusServicesToBeCalledTimes(1);
tick(5000);
expectPrometheusServicesToBeCalledTimes(2);
tick(15000);
expectPrometheusServicesToBeCalledTimes(5);
component.ngOnDestroy();
}));
});
});