This new method has the same behavior, but is type safe.
Fixes: https://tracker.ceph.com/issues/45326
Signed-off-by: Tiago Melo <tmelo@suse.com>
beforeEach(() => {
fixture = TestBed.createComponent(IscsiTargetDiscoveryModalComponent);
component = fixture.componentInstance;
- httpTesting = TestBed.get(HttpTestingController);
+ httpTesting = TestBed.inject(HttpTestingController);
});
describe('with update permissions', () => {
beforeEach(() => {
fixture = TestBed.createComponent(IscsiTargetFormComponent);
component = fixture.componentInstance;
- httpTesting = TestBed.get(HttpTestingController);
- activatedRoute = TestBed.get(ActivatedRoute);
+ httpTesting = TestBed.inject(HttpTestingController);
+ activatedRoute = <ActivatedRouteStub>TestBed.inject(ActivatedRoute);
fixture.detectChanges();
httpTesting.expectOne('ui-api/iscsi/settings').flush(SETTINGS);
beforeEach(() => {
fixture = TestBed.createComponent(IscsiTargetListComponent);
component = fixture.componentInstance;
- summaryService = TestBed.get(SummaryService);
- iscsiService = TestBed.get(IscsiService);
+ summaryService = TestBed.inject(SummaryService);
+ iscsiService = TestBed.inject(IscsiService);
// this is needed because summaryService isn't being reset after each test.
summaryService['summaryDataSource'] = new BehaviorSubject(null);
beforeEach(() => {
fixture = TestBed.createComponent(IscsiComponent);
component = fixture.componentInstance;
- iscsiService = TestBed.get(IscsiService);
+ iscsiService = TestBed.inject(IscsiService);
fixture.detectChanges();
tcmuiscsiData = {
images: []
component = fixture.componentInstance;
component.siteName = 'site-A';
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
- rbdMirroringService = TestBed.get(RbdMirroringService);
+ rbdMirroringService = TestBed.inject(RbdMirroringService);
formHelper = new FormHelper(component.createBootstrapForm);
component = fixture.componentInstance;
component.siteName = 'site-A';
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
- rbdMirroringService = TestBed.get(RbdMirroringService);
+ rbdMirroringService = TestBed.inject(RbdMirroringService);
formHelper = new FormHelper(component.importBootstrapForm);
component = fixture.componentInstance;
component.siteName = 'site-A';
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
- rbdMirroringService = TestBed.get(RbdMirroringService);
+ rbdMirroringService = TestBed.inject(RbdMirroringService);
});
it('should create', () => {
component = fixture.componentInstance;
component.poolName = 'somePool';
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
- rbdMirroringService = TestBed.get(RbdMirroringService);
+ rbdMirroringService = TestBed.inject(RbdMirroringService);
formHelper = new FormHelper(component.editModeForm);
fixture.detectChanges();
component.mode = 'add';
component.poolName = 'somePool';
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
- rbdMirroringService = TestBed.get(RbdMirroringService);
+ rbdMirroringService = TestBed.inject(RbdMirroringService);
formHelper = new FormHelper(component.editPeerForm);
});
component.form = new CdFormGroup({}, null);
fh = new FormHelper(component.form);
fixture.detectChanges();
- sections = TestBed.get(RbdConfigurationService).sections;
+ sections = TestBed.inject(RbdConfigurationService).sections;
});
it('should create', () => {
beforeEach(() => {
fixture = TestBed.createComponent(RbdFormComponent);
component = fixture.componentInstance;
- activatedRoute = TestBed.get(ActivatedRoute);
+ activatedRoute = <ActivatedRouteStub>TestBed.inject(ActivatedRoute);
component.loadingReady();
});
cloneAction = spyOn(component, 'cloneAction').and.returnValue(of(null));
copyAction = spyOn(component, 'copyAction').and.returnValue(of(null));
spyOn(component, 'setResponse').and.stub();
- routerNavigate = spyOn(TestBed.get(Router), 'navigate').and.stub();
- rbdServiceGetSpy = spyOn(TestBed.get(RbdService), 'get');
+ routerNavigate = spyOn(TestBed.inject(Router), 'navigate').and.stub();
+ rbdServiceGetSpy = spyOn(TestBed.inject(RbdService), 'get');
rbdServiceGetSpy.and.returnValue(of({ pool_name: 'foo', pool_image: 'bar' }));
component.mode = undefined;
});
let rbdService: RbdService;
beforeEach(() => {
- rbdService = TestBed.get(RbdService);
+ rbdService = TestBed.inject(RbdService);
component.mode = RbdFormMode.editing;
fixture.detectChanges();
spyOn(rbdService, 'get').and.callThrough();
describe('test edit form flags', () => {
const prepare = (pool: string, image: string, enabledFeatures: string[]): void => {
- const rbdService = TestBed.get(RbdService);
+ const rbdService = TestBed.inject(RbdService);
spyOn(rbdService, 'get').and.returnValue(
of({
name: image,
describe('test create form flags', () => {
beforeEach(() => {
- const rbdService = TestBed.get(RbdService);
+ const rbdService = TestBed.inject(RbdService);
spyOn(rbdService, 'defaultFeatures').and.returnValue(of(defaultFeatures));
component.router = { url: '/block/rbd/create' } as Router;
fixture.detectChanges();
beforeEach(() => {
fixture = TestBed.createComponent(RbdListComponent);
component = fixture.componentInstance;
- summaryService = TestBed.get(SummaryService);
- rbdService = TestBed.get(RbdService);
+ summaryService = TestBed.inject(SummaryService);
+ rbdService = TestBed.inject(RbdService);
// this is needed because summaryService isn't being reset after each test.
summaryService['summaryDataSource'] = new BehaviorSubject(null);
fixture = TestBed.createComponent(RbdSnapshotListComponent);
component = fixture.componentInstance;
component.ngOnChanges();
- summaryService = TestBed.get(SummaryService);
+ summaryService = TestBed.inject(SummaryService);
});
it('should create', () => {
beforeEach(() => {
fixture.detectChanges();
- const i18n = TestBed.get(I18n);
- const actionLabelsI18n = TestBed.get(ActionLabelsI18n);
+ const i18n = TestBed.inject(I18n);
+ const actionLabelsI18n = TestBed.inject(ActionLabelsI18n);
called = false;
rbdService = new RbdService(null, null);
notificationService = new NotificationService(null, null, null);
beforeEach(() => {
component.poolName = 'pool01';
component.rbdName = 'image01';
- spyOn(TestBed.get(BsModalService), 'show').and.callFake(() => {
+ spyOn(TestBed.inject(BsModalService), 'show').and.callFake(() => {
const ref = new BsModalRef();
ref.content = new RbdSnapshotFormModalComponent(
null,
null,
null,
null,
- TestBed.get(I18n),
- TestBed.get(ActionLabelsI18n)
+ TestBed.inject(I18n),
+ TestBed.inject(ActionLabelsI18n)
);
ref.content.onSubmit = new Subject();
return ref;
beforeEach(() => {
fixture = TestBed.createComponent(RbdTrashListComponent);
component = fixture.componentInstance;
- summaryService = TestBed.get(SummaryService);
- rbdService = TestBed.get(RbdService);
+ summaryService = TestBed.inject(SummaryService);
+ rbdService = TestBed.inject(RbdService);
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(RbdTrashMoveModalComponent);
component = fixture.componentInstance;
- httpTesting = TestBed.get(HttpTestingController);
+ httpTesting = TestBed.inject(HttpTestingController);
component.poolName = 'foo';
component.imageName = 'bar';
let notificationService: NotificationService;
beforeEach(() => {
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
spyOn(component.modalRef, 'hide').and.callThrough();
});
beforeEach(() => {
fixture = TestBed.createComponent(RbdTrashPurgeModalComponent);
- httpTesting = TestBed.get(HttpTestingController);
+ httpTesting = TestBed.inject(HttpTestingController);
component = fixture.componentInstance;
});
beforeEach(() => {
fixture.detectChanges();
- notificationService = TestBed.get(NotificationService);
- modalRef = TestBed.get(BsModalRef);
+ notificationService = TestBed.inject(NotificationService);
+ modalRef = TestBed.inject(BsModalRef);
component.purgeForm.patchValue({ poolName: 'foo' });
let req: TestRequest;
beforeEach(() => {
- httpTesting = TestBed.get(HttpTestingController);
- notificationService = TestBed.get(NotificationService);
- modalRef = TestBed.get(BsModalRef);
+ httpTesting = TestBed.inject(HttpTestingController);
+ notificationService = TestBed.inject(NotificationService);
+ modalRef = TestBed.inject(BsModalRef);
component.poolName = 'foo';
component.imageName = 'bar';
updatedQuotas: {}
};
- cephfsService = TestBed.get(CephfsService);
+ cephfsService = TestBed.inject(CephfsService);
lsDirSpy = spyOn(cephfsService, 'lsDir').and.callFake(mockLib.lsDir);
spyOn(cephfsService, 'mkSnapshot').and.callFake(mockLib.mkSnapshot);
spyOn(cephfsService, 'rmSnapshot').and.callFake(mockLib.rmSnapshot);
spyOn(cephfsService, 'updateQuota').and.callFake(mockLib.updateQuota);
- modalShowSpy = spyOn(TestBed.get(BsModalService), 'show').and.callFake(mockLib.modalShow);
- notificationShowSpy = spyOn(TestBed.get(NotificationService), 'show').and.stub();
+ modalShowSpy = spyOn(TestBed.inject(BsModalService), 'show').and.callFake(mockLib.modalShow);
+ notificationShowSpy = spyOn(TestBed.inject(NotificationService), 'show').and.stub();
fixture = TestBed.createComponent(CephfsDirectoriesComponent);
component = fixture.componentInstance;
data: [{}, {}, {}, {}]
}
};
- service = TestBed.get(CephfsService);
+ service = TestBed.inject(CephfsService);
spyOn(service, 'getTabs').and.callFake(() => of(data));
fixture.detectChanges();
beforeEach(() => {
fixture = TestBed.createComponent(HostsComponent);
component = fixture.componentInstance;
- hostListSpy = spyOn(TestBed.get(HostService), 'list');
+ hostListSpy = spyOn(TestBed.inject(HostService), 'list');
fixture.detectChanges();
});
beforeEach(() => {
fixture = TestBed.createComponent(InventoryComponent);
component = fixture.componentInstance;
- orchService = TestBed.get(OrchestratorService);
+ orchService = TestBed.inject(OrchestratorService);
spyOn(orchService, 'status').and.returnValue(of({ available: true }));
spyOn(orchService, 'inventoryDeviceList').and.callThrough();
});
beforeEach(() => {
fixture = TestBed.createComponent(MgrModuleListComponent);
component = fixture.componentInstance;
- mgrModuleService = TestBed.get(MgrModuleService);
- notificationService = TestBed.get(NotificationService);
+ mgrModuleService = TestBed.inject(MgrModuleService);
+ notificationService = TestBed.inject(NotificationService);
});
it('should create', () => {
mon_status: null,
out_quorum: []
};
- getMonitorSpy = spyOn(TestBed.get(MonitorService), 'getMonitor').and.returnValue(
+ getMonitorSpy = spyOn(TestBed.inject(MonitorService), 'getMonitor').and.returnValue(
of(getMonitorPayload)
);
});
});
beforeEach(() => {
- httpTesting = TestBed.get(HttpTestingController);
+ httpTesting = TestBed.inject(HttpTestingController);
fixture = TestBed.createComponent(OsdFlagsModalComponent);
component = fixture.componentInstance;
});
let bsModalRef: BsModalRef;
beforeEach(() => {
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.callFake((type) => {
notificationType = type;
});
- bsModalRef = TestBed.get(BsModalRef);
+ bsModalRef = TestBed.inject(BsModalRef);
spyOn(bsModalRef, 'hide').and.callThrough();
component.unknownFlags = ['foo'];
});
component = fixture.componentInstance;
form = component.form;
formHelper = new FormHelper(form);
- orchService = TestBed.get(OrchestratorService);
- summaryService = TestBed.get(SummaryService);
+ orchService = TestBed.inject(OrchestratorService);
+ summaryService = TestBed.inject(SummaryService);
summaryService['summaryDataSource'] = new BehaviorSubject(null);
summaryService['summaryData$'] = summaryService['summaryDataSource'].asObservable();
summaryService['summaryDataSource'].next({ version: 'master' });
* we will have to fake its request to be able to open those modals.
*/
const mockSafeToDestroy = () => {
- spyOn(TestBed.get(OsdService), 'safeToDestroy').and.callFake(() =>
+ spyOn(TestBed.inject(OsdService), 'safeToDestroy').and.callFake(() =>
of({ is_safe_to_destroy: true })
);
};
const mockSafeToDelete = () => {
- spyOn(TestBed.get(OsdService), 'safeToDelete').and.callFake(() =>
+ spyOn(TestBed.inject(OsdService), 'safeToDelete').and.callFake(() =>
of({ is_safe_to_delete: true })
);
};
const mockOrchestratorStatus = () => {
- spyOn(TestBed.get(OrchestratorService), 'status').and.callFake(() => of({ available: true }));
+ spyOn(TestBed.inject(OrchestratorService), 'status').and.callFake(() =>
+ of({ available: true })
+ );
};
configureTestBed({
beforeEach(() => {
fixture = TestBed.createComponent(OsdListComponent);
component = fixture.componentInstance;
- osdService = TestBed.get(OsdService);
- modalServiceShowSpy = spyOn(TestBed.get(BsModalService), 'show').and.stub();
+ osdService = TestBed.inject(OsdService);
+ modalServiceShowSpy = spyOn(TestBed.inject(BsModalService), 'show').and.stub();
});
it('should create', () => {
it('has all menu entries disabled except create', () => {
const tableActionElement = fixture.debugElement.query(By.directive(TableActionsComponent));
- const toClassName = TestBed.get(TableActionsComponent).toClassName;
+ const toClassName = TestBed.inject(TableActionsComponent).toClassName;
const getActionClasses = (action: CdTableAction) =>
tableActionElement.query(By.css(`.${toClassName(action.name)} .dropdown-item`)).classes;
fixture = TestBed.createComponent(OsdPgScrubModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- configurationService = TestBed.get(ConfigurationService);
+ configurationService = TestBed.inject(ConfigurationService);
});
it('should create', () => {
let notificationService: NotificationService;
beforeEach(() => {
- spyOn(TestBed.get(Router), 'navigate').and.stub();
- notificationService = TestBed.get(NotificationService);
+ spyOn(TestBed.inject(Router), 'navigate').and.stub();
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show');
});
fixture = TestBed.createComponent(OsdRecvSpeedModalComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- configurationService = TestBed.get(ConfigurationService);
+ configurationService = TestBed.inject(ConfigurationService);
configOptions = [
{
name: 'osd_max_backfills',
component.osdId = 1;
component.reweightForm.get('weight').setValue(0.5);
- const osdServiceSpy = spyOn(TestBed.get(OsdService), 'reweight').and.callFake(() => of(true));
+ const osdServiceSpy = spyOn(TestBed.inject(OsdService), 'reweight').and.callFake(() =>
+ of(true)
+ );
component.reweight();
expect(osdServiceSpy.calls.count()).toBe(1);
spyOn(global, 'Date').and.callFake((arg) => (arg ? new originalDate(arg) : beginningDate));
prometheus = new PrometheusHelper();
- prometheusService = TestBed.get(PrometheusService);
+ prometheusService = TestBed.inject(PrometheusService);
spyOn(prometheusService, 'getAlerts').and.callFake(() =>
of([prometheus.createAlert('alert0')])
);
})
);
- router = TestBed.get(Router);
+ router = TestBed.inject(Router);
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
- authStorageService = TestBed.get(AuthStorageService);
+ authStorageService = TestBed.inject(AuthStorageService);
spyOn(authStorageService, 'getUsername').and.returnValue('someUser');
fixture = TestBed.createComponent(SilenceFormComponent);
addMatcher('alertname', 'alert.*', true);
expectMatch(null);
- const modalService = TestBed.get(BsModalService);
+ const modalService = TestBed.inject(BsModalService);
spyOn(modalService, 'show').and.callFake(() => {
return {
content: {
beforeEach(() => {
fixture = TestBed.createComponent(SilenceListComponent);
component = fixture.componentInstance;
- prometheusService = TestBed.get(PrometheusService);
+ prometheusService = TestBed.inject(PrometheusService);
});
it('should create', () => {
const mockObservable = () => of([]);
spyOn(component, 'refresh').and.callFake(mockObservable);
spyOn(prometheusService, 'expireSilence').and.callFake(mockObservable);
- spyOn(TestBed.get(BsModalService), 'show').and.callFake((deletionClass, config) => {
+ spyOn(TestBed.inject(BsModalService), 'show').and.callFake((deletionClass, config) => {
return {
content: Object.assign(new deletionClass(), config.initialState)
};
});
it('should expire a silence', () => {
- const notificationService = TestBed.get(NotificationService);
+ const notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
expectSilenceToExpire('someSilenceId');
expect(notificationService.show).toHaveBeenCalledWith(
beforeEach(() => {
fixture = TestBed.createComponent(ServiceDaemonListComponent);
component = fixture.componentInstance;
- const hostService = TestBed.get(HostService);
- const cephServiceService = TestBed.get(CephServiceService);
+ const hostService = TestBed.inject(HostService);
+ const cephServiceService = TestBed.inject(CephServiceService);
spyOn(hostService, 'getDaemons').and.callFake(() =>
of(getDaemonsByHostname(component.hostname))
);
beforeEach(() => {
fixture = TestBed.createComponent(ServicesComponent);
component = fixture.componentInstance;
- const orchService = TestBed.get(OrchestratorService);
- const cephServiceService = TestBed.get(CephServiceService);
+ const orchService = TestBed.inject(OrchestratorService);
+ const cephServiceService = TestBed.inject(CephServiceService);
spyOn(orchService, 'status').and.returnValue(of({ available: true }));
spyOn(cephServiceService, 'list').and.returnValue(of(services));
fixture.detectChanges();
beforeEach(() => {
fixture = TestBed.createComponent(TelemetryComponent);
component = fixture.componentInstance;
- mgrModuleService = TestBed.get(MgrModuleService);
+ mgrModuleService = TestBed.inject(MgrModuleService);
options = {};
configs = {};
optionsNames.forEach((name) => (options[name] = { name }));
spyOn(mgrModuleService, 'getOptions').and.callFake(() => observableOf(options));
spyOn(mgrModuleService, 'getConfig').and.callFake(() => observableOf(configs));
fixture.detectChanges();
- httpTesting = TestBed.get(HttpTestingController);
- router = TestBed.get(Router);
+ httpTesting = TestBed.inject(HttpTestingController);
+ router = TestBed.inject(Router);
spyOn(router, 'navigate');
});
fixture = TestBed.createComponent(TelemetryComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- telemetryService = TestBed.get(TelemetryService);
- httpTesting = TestBed.get(HttpTestingController);
- router = TestBed.get(Router);
+ telemetryService = TestBed.inject(TelemetryService);
+ httpTesting = TestBed.inject(HttpTestingController);
+ router = TestBed.inject(Router);
spyOn(router, 'navigate');
});
spyOn(telemetryService, 'getReport').and.returnValue(observableOf(reportText));
component.ngOnInit();
- const downloadSpy = spyOn(TestBed.get(TextToDownloadService), 'download');
+ const downloadSpy = spyOn(TestBed.inject(TextToDownloadService), 'download');
const filename = 'reportText.json';
component.download(reportText, filename);
expect(downloadSpy).toHaveBeenCalledWith(JSON.stringify(reportText, null, 2), filename);
});
beforeEach(() => {
- fakeFeatureTogglesService = spyOn(TestBed.get(FeatureTogglesService), 'get').and.returnValue(
+ fakeFeatureTogglesService = spyOn(TestBed.inject(FeatureTogglesService), 'get').and.returnValue(
of({
rbd: true,
mirroring: true,
);
fixture = TestBed.createComponent(HealthComponent);
component = fixture.componentInstance;
- getHealthSpy = spyOn(TestBed.get(HealthService), 'getMinimalHealth');
+ getHealthSpy = spyOn(TestBed.inject(HealthService), 'getMinimalHealth');
getHealthSpy.and.returnValue(of(healthPayload));
});
});
beforeEach(() => {
- pipe = TestBed.get(MdsSummaryPipe);
+ pipe = TestBed.inject(MdsSummaryPipe);
});
it('create an instance', () => {
});
beforeEach(() => {
- pipe = TestBed.get(MgrSummaryPipe);
+ pipe = TestBed.inject(MgrSummaryPipe);
});
it('create an instance', () => {
});
beforeEach(() => {
- pipe = TestBed.get(MonSummaryPipe);
+ pipe = TestBed.inject(MonSummaryPipe);
});
it('create an instance', () => {
});
beforeEach(() => {
- pipe = TestBed.get(OsdSummaryPipe);
+ pipe = TestBed.inject(OsdSummaryPipe);
});
it('create an instance', () => {
beforeEach(() => {
fixture = TestBed.createComponent(NfsFormClientComponent);
- const formBuilder = TestBed.get(CdFormBuilder);
+ const formBuilder = TestBed.inject(CdFormBuilder);
component = fixture.componentInstance;
component.form = new CdFormGroup({
});
beforeEach(() => {
- const summaryService = TestBed.get(SummaryService);
+ const summaryService = TestBed.inject(SummaryService);
spyOn(summaryService, 'refresh').and.callFake(() => true);
spyOn(summaryService, 'subscribeOnce').and.callFake(() =>
of({
fixture = TestBed.createComponent(NfsFormComponent);
component = fixture.componentInstance;
- httpTesting = TestBed.get(HttpTestingController);
- activatedRoute = TestBed.get(ActivatedRoute);
+ httpTesting = TestBed.inject(HttpTestingController);
+ activatedRoute = <ActivatedRouteStub>TestBed.inject(ActivatedRoute);
fixture.detectChanges();
httpTesting.expectOne('api/nfs-ganesha/daemon').flush([
beforeEach(() => {
fixture = TestBed.createComponent(NfsListComponent);
component = fixture.componentInstance;
- summaryService = TestBed.get(SummaryService);
- nfsService = TestBed.get(NfsService);
- httpTesting = TestBed.get(HttpTestingController);
+ summaryService = TestBed.inject(SummaryService);
+ nfsService = TestBed.inject(NfsService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
it('should create', () => {
beforeEach(() => {
fixture = TestBed.createComponent(TablePerformanceCounterComponent);
component = fixture.componentInstance;
- httpTesting = TestBed.get(HttpTestingController);
+ httpTesting = TestBed.inject(HttpTestingController);
fixture.detectChanges();
});
fixtureHelper = new FixtureHelper(fixture);
component = fixture.componentInstance;
formHelper = new FormHelper(component.form);
- crushRuleService = TestBed.get(CrushRuleService);
+ crushRuleService = TestBed.inject(CrushRuleService);
data = {
names: ['rule1', 'rule2'],
/**
describe('submission', () => {
beforeEach(() => {
- const taskWrapper = TestBed.get(TaskWrapperService);
+ const taskWrapper = TestBed.inject(TaskWrapperService);
spyOn(taskWrapper, 'wrapTaskAroundCall').and.callThrough();
spyOn(crushRuleService, 'create').and.stub();
});
fixtureHelper = new FixtureHelper(fixture);
component = fixture.componentInstance;
formHelper = new FormHelper(component.form);
- ecpService = TestBed.get(ErasureCodeProfileService);
+ ecpService = TestBed.inject(ErasureCodeProfileService);
data = {
plugins: ['isa', 'jerasure', 'shec', 'lrc'],
names: ['ecp1', 'ecp2'],
submittedEcp['packetsize'] = 2048;
submittedEcp['technique'] = 'reed_sol_van';
- const taskWrapper = TestBed.get(TaskWrapperService);
+ const taskWrapper = TestBed.inject(TaskWrapperService);
spyOn(taskWrapper, 'wrapTaskAroundCall').and.callThrough();
spyOn(ecpService, 'create').and.stub();
});
poolServiceMethod: 'create' | 'update' = 'create'
) => {
spyOn(poolService, poolServiceMethod).and.stub();
- const taskWrapper = TestBed.get(TaskWrapperService);
+ const taskWrapper = TestBed.inject(TaskWrapperService);
spyOn(taskWrapper, 'wrapTaskAroundCall').and.callThrough();
component.submit();
expect(poolService[poolServiceMethod]).toHaveBeenCalledWith(pool);
let navigationSpy: jasmine.Spy;
beforeEach(() => {
- poolService = TestBed.get(PoolService);
+ poolService = TestBed.inject(PoolService);
setInfo();
spyOn(poolService, 'getInfo').and.callFake(() => of(infoReturn));
- ecpService = TestBed.get(ErasureCodeProfileService);
- crushRuleService = TestBed.get(CrushRuleService);
+ ecpService = TestBed.inject(ErasureCodeProfileService);
+ crushRuleService = TestBed.inject(CrushRuleService);
- router = TestBed.get(Router);
+ router = TestBed.inject(Router);
navigationSpy = spyOn(router, 'navigate').and.stub();
setUpPoolComponent();
read: false,
delete: false
};
- authStorageService = TestBed.get(AuthStorageService);
+ authStorageService = TestBed.inject(AuthStorageService);
spyOn(authStorageService, 'getPermissions').and.callFake(() => ({
pool: poolPermissions
}));
it('should select the newly created rule', () => {
expect(form.getValue('crushRule').rule_name).toBe('rep1');
const name = 'awesomeRule';
- spyOn(TestBed.get(BsModalService), 'show').and.callFake(() => {
+ spyOn(TestBed.inject(BsModalService), 'show').and.callFake(() => {
return {
content: {
submitAction: of({ name })
};
beforeEach(() => {
- modalSpy = spyOn(TestBed.get(BsModalService), 'show').and.callFake(
+ modalSpy = spyOn(TestBed.inject(BsModalService), 'show').and.callFake(
(deletionClass: any, config: any) => {
deletion = Object.assign(new deletionClass(), config.initialState);
return {
rules.splice(index, 1);
return of(undefined);
});
- taskWrapper = TestBed.get(TaskWrapperService);
+ taskWrapper = TestBed.inject(TaskWrapperService);
spyOn(taskWrapper, 'wrapTaskAroundCall').and.callThrough();
});
spyOn(ecpService, 'list').and.callFake(() => of(infoReturn.erasure_code_profiles));
expect(form.getValue('erasureProfile').name).toBe('ecp1');
const name = 'awesomeProfile';
- spyOn(TestBed.get(BsModalService), 'show').and.callFake(() => {
+ spyOn(TestBed.inject(BsModalService), 'show').and.callFake(() => {
return {
content: {
submitAction: of({ name })
beforeEach(() => {
deletion = undefined;
- modalSpy = spyOn(TestBed.get(BsModalService), 'show').and.callFake(
+ modalSpy = spyOn(TestBed.inject(BsModalService), 'show').and.callFake(
(comp: any, init: any) => {
modal = modalServiceShow(comp, init);
return modal.ref;
profiles.splice(index, 1);
return of({ status: 202 });
});
- taskWrapper = TestBed.get(TaskWrapperService);
+ taskWrapper = TestBed.inject(TaskWrapperService);
spyOn(taskWrapper, 'wrapTaskAroundCall').and.callThrough();
const ecp2 = new ErasureCodeProfile();
fixture = TestBed.createComponent(PoolListComponent);
component = fixture.componentInstance;
component.permissions.pool.read = true;
- poolService = TestBed.get(PoolService);
+ poolService = TestBed.inject(PoolService);
spyOn(poolService, 'getList').and.callFake(() => of(getPoolList()));
fixture.detectChanges();
});
beforeEach(() => {
configOptRead = true;
- spyOn(TestBed.get(AuthStorageService), 'getPermissions').and.callFake(() => ({
+ spyOn(TestBed.inject(AuthStorageService), 'getPermissions').and.callFake(() => ({
configOpt: { read: configOptRead }
}));
- configurationService = TestBed.get(ConfigurationService);
+ configurationService = TestBed.inject(ConfigurationService);
});
it('should set value correctly if mon_allow_pool_delete flag is set to true', () => {
};
beforeEach(() => {
- spyOn(TestBed.get(BsModalService), 'show').and.callFake((deletionClass, config) => {
+ spyOn(TestBed.inject(BsModalService), 'show').and.callFake((deletionClass, config) => {
return {
content: Object.assign(new deletionClass(), config.initialState)
};
});
spyOn(poolService, 'delete').and.stub();
- taskWrapper = TestBed.get(TaskWrapperService);
+ taskWrapper = TestBed.inject(TaskWrapperService);
spyOn(taskWrapper, 'wrapTaskAroundCall').and.callThrough();
});
};
beforeEach(() => {
- summaryService = TestBed.get(SummaryService);
+ summaryService = TestBed.inject(SummaryService);
summaryService['summaryDataSource'].next({
executing_tasks: [],
finished_tasks: []
beforeEach(() => {
fixture = TestBed.createComponent(RgwBucketFormComponent);
component = fixture.componentInstance;
- rgwBucketService = TestBed.get(RgwBucketService);
+ rgwBucketService = TestBed.inject(RgwBucketService);
rgwBucketServiceGetSpy = spyOn(rgwBucketService, 'get');
- getPlacementTargetsSpy = spyOn(TestBed.get(RgwSiteService), 'get');
- enumerateSpy = spyOn(TestBed.get(RgwUserService), 'enumerate');
+ getPlacementTargetsSpy = spyOn(TestBed.inject(RgwSiteService), 'get');
+ enumerateSpy = spyOn(TestBed.inject(RgwUserService), 'enumerate');
formHelper = new FormHelper(component.bucketForm);
});
let notificationService: NotificationService;
beforeEach(() => {
- spyOn(TestBed.get(Router), 'navigate').and.stub();
- notificationService = TestBed.get(NotificationService);
+ spyOn(TestBed.inject(Router), 'navigate').and.stub();
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show');
});
});
beforeEach(() => {
- getPermissionsSpy = spyOn(TestBed.get(AuthStorageService), 'getPermissions');
+ getPermissionsSpy = spyOn(TestBed.inject(AuthStorageService), 'getPermissions');
getPermissionsSpy.and.returnValue(new Permissions({}));
- getRealmsSpy = spyOn(TestBed.get(RgwSiteService), 'get');
+ getRealmsSpy = spyOn(TestBed.inject(RgwSiteService), 'get');
getRealmsSpy.and.returnValue(of([]));
fixture = TestBed.createComponent(RgwDaemonListComponent);
component = fixture.componentInstance;
fixture = TestBed.createComponent(RgwUserFormComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- rgwUserService = TestBed.get(RgwUserService);
+ rgwUserService = TestBed.inject(RgwUserService);
formHelper = new FormHelper(component.userForm);
});
let notificationService: NotificationService;
beforeEach(() => {
- spyOn(TestBed.get(Router), 'navigate').and.stub();
- notificationService = TestBed.get(NotificationService);
+ spyOn(TestBed.inject(Router), 'navigate').and.stub();
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show');
});
});
beforeEach(() => {
- service = TestBed.get(PgCategoryService);
+ service = TestBed.inject(PgCategoryService);
});
it('should be created', () => {
component = fixture.componentInstance;
fixture.detectChanges();
- osdService = TestBed.get(OsdService);
+ osdService = TestBed.inject(OsdService);
});
it('should create', () => {
beforeEach(() => {
fixture = TestBed.createComponent(LoginPasswordFormComponent);
component = fixture.componentInstance;
- httpTesting = TestBed.get(HttpTestingController);
- router = TestBed.get(Router);
- authStorageService = TestBed.get(AuthStorageService);
- authService = TestBed.get(AuthService);
+ httpTesting = TestBed.inject(HttpTestingController);
+ router = TestBed.inject(Router);
+ authStorageService = TestBed.inject(AuthStorageService);
+ authService = TestBed.inject(AuthService);
spyOn(router, 'navigate');
fixture.detectChanges();
form = component.userForm;
fixture = TestBed.createComponent(RoleFormComponent);
component = fixture.componentInstance;
form = component.roleForm;
- httpTesting = TestBed.get(HttpTestingController);
- roleService = TestBed.get(RoleService);
- router = TestBed.get(Router);
+ httpTesting = TestBed.inject(HttpTestingController);
+ roleService = TestBed.inject(RoleService);
+ router = TestBed.inject(Router);
spyOn(router, 'navigate');
fixture.detectChanges();
- const notify = TestBed.get(NotificationService);
+ const notify = TestBed.inject(NotificationService);
spyOn(notify, 'show');
});
const scopes = ['osd', 'user'];
beforeEach(() => {
spyOn(roleService, 'get').and.callFake(() => of(role));
- spyOn(TestBed.get(ScopeService), 'list').and.callFake(() => of(scopes));
+ spyOn(TestBed.inject(ScopeService), 'list').and.callFake(() => of(scopes));
setUrl('/user-management/roles/edit/role1');
component.ngOnInit();
const reqScopes = httpTesting.expectOne('ui-api/scope');
});
beforeEach(() => {
- spyOn(TestBed.get(PasswordPolicyService), 'getHelpText').and.callFake(() => of(''));
+ spyOn(TestBed.inject(PasswordPolicyService), 'getHelpText').and.callFake(() => of(''));
fixture = TestBed.createComponent(UserFormComponent);
component = fixture.componentInstance;
form = component.userForm;
- httpTesting = TestBed.get(HttpTestingController);
- userService = TestBed.get(UserService);
- modalService = TestBed.get(BsModalService);
- router = TestBed.get(Router);
+ httpTesting = TestBed.inject(HttpTestingController);
+ userService = TestBed.inject(UserService);
+ modalService = TestBed.inject(BsModalService);
+ router = TestBed.inject(Router);
spyOn(router, 'navigate');
fixture.detectChanges();
- const notify = TestBed.get(NotificationService);
+ const notify = TestBed.inject(NotificationService);
spyOn(notify, 'show');
formHelper = new FormHelper(form);
});
beforeEach(() => {
spyOn(userService, 'get').and.callFake(() => of(user));
- spyOn(TestBed.get(RoleService), 'list').and.callFake(() => of(roles));
+ spyOn(TestBed.inject(RoleService), 'list').and.callFake(() => of(roles));
setUrl('/user-management/users/edit/user1');
- spyOn(TestBed.get(SettingsService), 'getStandardSettings').and.callFake(() =>
+ spyOn(TestBed.inject(SettingsService), 'getStandardSettings').and.callFake(() =>
of({
user_pwd_expiration_warning_1: 10,
user_pwd_expiration_warning_2: 5,
});
it('should alert if user is removing needed role permission', () => {
- spyOn(TestBed.get(AuthStorageService), 'getUsername').and.callFake(() => user.username);
+ spyOn(TestBed.inject(AuthStorageService), 'getUsername').and.callFake(() => user.username);
let modalBodyTpl = null;
spyOn(modalService, 'show').and.callFake((_content, config) => {
modalBodyTpl = config.initialState.bodyTpl;
});
it('should logout if current user roles have been changed', () => {
- spyOn(TestBed.get(AuthStorageService), 'getUsername').and.callFake(() => user.username);
+ spyOn(TestBed.inject(AuthStorageService), 'getUsername').and.callFake(() => user.username);
formHelper.setValue('roles', ['user-manager']);
component.submit();
const userReq = httpTesting.expectOne(`api/user/${user.username}`);
});
it('should submit', () => {
- spyOn(TestBed.get(AuthStorageService), 'getUsername').and.callFake(() => user.username);
+ spyOn(TestBed.inject(AuthStorageService), 'getUsername').and.callFake(() => user.username);
component.submit();
const userReq = httpTesting.expectOne(`api/user/${user.username}`);
expect(userReq.request.method).toBe('PUT');
fixture = TestBed.createComponent(UserPasswordFormComponent);
component = fixture.componentInstance;
form = component.userForm;
- httpTesting = TestBed.get(HttpTestingController);
- router = TestBed.get(Router);
- authStorageService = TestBed.get(AuthStorageService);
+ httpTesting = TestBed.inject(HttpTestingController);
+ router = TestBed.inject(Router);
+ authStorageService = TestBed.inject(AuthStorageService);
spyOn(router, 'navigate');
fixture.detectChanges();
formHelper = new FormHelper(form);
beforeEach(() => {
fixture = TestBed.createComponent(BreadcrumbsComponent);
- router = TestBed.get(Router);
+ router = TestBed.inject(Router);
component = fixture.componentInstance;
fixture.detectChanges();
expect(component.crumbs).toEqual([]);
beforeEach(() => {
fixture = TestBed.createComponent(NotificationsComponent);
component = fixture.componentInstance;
- summaryService = TestBed.get(SummaryService);
+ summaryService = TestBed.inject(SummaryService);
fixture.detectChanges();
});
});
beforeEach(() => {
- service = TestBed.get(AuthService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(AuthService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
}));
it('should logout and remove the user', () => {
- const router = TestBed.get(Router);
+ const router = TestBed.inject(Router);
spyOn(router, 'navigate').and.stub();
service.logout();
});
beforeEach(() => {
- service = TestBed.get(CephfsService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(CephfsService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(ConfigurationService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(ConfigurationService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(CrushRuleService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(CrushRuleService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(ErasureCodeProfileService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(ErasureCodeProfileService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(HealthService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(HealthService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(HostService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(HostService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(IscsiService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(IscsiService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(LoggingService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(LoggingService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(LogsService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(LogsService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(MgrModuleService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(MgrModuleService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(MonitorService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(MonitorService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(NfsService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(NfsService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(OrchestratorService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(OrchestratorService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(OsdService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(OsdService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(PerformanceCounterService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(PerformanceCounterService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(PoolService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(PoolService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(PrometheusService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(PrometheusService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
beforeEach(() => {
x = false;
- TestBed.get(SettingsService)['settings'] = {};
+ TestBed.inject(SettingsService)['settings'] = {};
service.ifAlertmanagerConfigured(
(v) => (x = v),
() => (x = [])
beforeEach(() => {
x = false;
- TestBed.get(SettingsService)['settings'] = {};
+ TestBed.inject(SettingsService)['settings'] = {};
service.ifPrometheusConfigured(
(v) => (x = v),
() => (x = [])
});
beforeEach(() => {
- service = TestBed.get(RbdMirroringService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(RbdMirroringService);
+ httpTesting = TestBed.inject(HttpTestingController);
getMirroringSummaryCalls = () => {
return httpTesting.match((request: HttpRequest<any>) => {
return request.url.match(/api\/block\/mirroring\/summary/) && request.method === 'GET';
});
beforeEach(() => {
- service = TestBed.get(RbdService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(RbdService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(RgwBucketService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(RgwBucketService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(RgwDaemonService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(RgwDaemonService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(RgwSiteService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(RgwSiteService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(RgwUserService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(RgwUserService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(RoleService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(RoleService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(ScopeService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(ScopeService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(SettingsService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(SettingsService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(TelemetryService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(TelemetryService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(UserService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(UserService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
fixture = TestBed.createComponent(ConfigOptionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
- configurationService = TestBed.get(ConfigurationService);
+ configurationService = TestBed.inject(ConfigurationService);
const configOptions: Record<string, any> = [
{
mockFixture = TestBed.createComponent(MockComponent);
mockComponent = mockFixture.componentInstance;
mockFixture.detectChanges();
- modalService = TestBed.get(BsModalService);
+ modalService = TestBed.inject(BsModalService);
spyOn(modalService, 'show').and.callFake((_modalComp, config) => {
const data = modalServiceShow(ConfirmationModalComponent, config);
fixture = data.fixture;
import { RouterTestingModule } from '@angular/router/testing';
import { AlertModule } from 'ngx-bootstrap/alert';
+import { of } from 'rxjs';
import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
import { SummaryService } from '../../../shared/services/summary.service';
describe('with grafana initialized', () => {
beforeEach(() => {
- TestBed.get(SettingsService).settings = { 'api/grafana/url': 'http:localhost:3000' };
+ TestBed.inject(SettingsService)['settings'] = { 'api/grafana/url': 'http:localhost:3000' };
fixture.detectChanges();
});
});
it('should have Dashboard', () => {
- TestBed.get(SettingsService).validateGrafanaDashboardUrl = { uid: 200 };
+ TestBed.inject(SettingsService).validateGrafanaDashboardUrl = () => of({ uid: 200 });
expect(component.dashboardExist).toBe(true);
});
});
beforeEach(() => {
prometheusReadPermission = 'read';
configOptReadPermission = 'read';
- spyOn(TestBed.get(AuthStorageService), 'getPermissions').and.callFake(
+ spyOn(TestBed.inject(AuthStorageService), 'getPermissions').and.callFake(
() =>
new Permissions({
prometheus: [prometheusReadPermission],
})
);
- spyOn(TestBed.get(PrometheusService), 'ifAlertmanagerConfigured').and.callFake((fn) => fn());
+ spyOn(TestBed.inject(PrometheusService), 'ifAlertmanagerConfigured').and.callFake((fn) =>
+ fn()
+ );
- prometheusAlertService = TestBed.get(PrometheusAlertService);
+ prometheusAlertService = TestBed.inject(PrometheusAlertService);
spyOn(prometheusAlertService, 'refresh').and.stub();
- prometheusNotificationService = TestBed.get(PrometheusNotificationService);
+ prometheusNotificationService = TestBed.inject(PrometheusNotificationService);
spyOn(prometheusNotificationService, 'refresh').and.stub();
});
beforeEach(() => {
fixture.detectChanges();
- summaryService = TestBed.get(SummaryService);
+ summaryService = TestBed.inject(SummaryService);
spyOn(component, '_handleTasks').and.callThrough();
});
describe('Notifications', () => {
it('should fetch latest notifications', fakeAsync(() => {
- const notificationService: NotificationService = TestBed.get(NotificationService);
+ const notificationService: NotificationService = TestBed.inject(NotificationService);
fixture.detectChanges();
expect(component.notifications.length).toBe(0);
let notificationService: NotificationService;
beforeEach(() => {
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
fixture.detectChanges();
});
describe('password expiration date has been set', () => {
beforeEach(() => {
- authStorageService = TestBed.get(AuthStorageService);
- settingsService = TestBed.get(SettingsService);
+ authStorageService = TestBed.inject(AuthStorageService);
+ settingsService = TestBed.inject(SettingsService);
spyOn(authStorageService, 'getPwdExpirationDate').and.returnValue(1645488000);
spyOn(settingsService, 'getStandardSettings').and.returnValue(
observableOf({
describe('password expiration date has not been set', () => {
beforeEach(() => {
- authStorageService = TestBed.get(AuthStorageService);
+ authStorageService = TestBed.inject(AuthStorageService);
spyOn(authStorageService, 'getPwdExpirationDate').and.returnValue(null);
fixture = TestBed.createComponent(PwdExpirationNotificationComponent);
component = fixture.componentInstance;
{ name: 'option1', description: '', selected: false, enabled: true },
{ name: 'option2', description: '', selected: false, enabled: true }
];
- const i18n = TestBed.get(I18n);
+ const i18n = TestBed.inject(I18n);
const messages = new SelectMessages({ empty: 'foo bar' }, i18n);
const selectionLimit = 2;
const customBadges = true;
let datePipe: CdDatePipe;
beforeEach(() => {
- datePipe = TestBed.get(CdDatePipe);
+ datePipe = TestBed.inject(CdDatePipe);
spyOn(datePipe, 'transform').and.callThrough();
});
});
it('should create an instance', () => {
- const i18n = TestBed.get(I18n);
+ const i18n = TestBed.inject(I18n);
const directive = new Copy2ClipboardButtonDirective(null, null, null, i18n);
expect(directive).toBeTruthy();
});
});
beforeEach(() => {
- const i18n = TestBed.get(I18n);
+ const i18n = TestBed.inject(I18n);
pipe = new BooleanTextPipe(i18n);
});
});
beforeEach(() => {
- const i18n = TestBed.get(I18n);
+ const i18n = TestBed.inject(I18n);
pipe = new NotAvailablePipe(i18n);
});
const baseTime = new Date('2022-02-22');
spyOn(global, 'Date').and.returnValue(baseTime);
- httpClient = TestBed.get(HttpClient);
- httpTesting = TestBed.get(HttpTestingController);
+ httpClient = TestBed.inject(HttpClient);
+ httpTesting = TestBed.inject(HttpTestingController);
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.callThrough();
spyOn(notificationService, 'save');
- router = TestBed.get(Router);
+ router = TestBed.inject(Router);
spyOn(router, 'navigate');
});
it('should be created', () => {
- const service = TestBed.get(ApiInterceptorService);
+ const service = TestBed.inject(ApiInterceptorService);
expect(service).toBeTruthy();
});
});
beforeEach(() => {
- service = TestBed.get(AuthGuardService);
- authStorageService = TestBed.get(AuthStorageService);
- ngZone = TestBed.get(NgZone);
+ service = TestBed.inject(AuthGuardService);
+ authStorageService = TestBed.inject(AuthStorageService);
+ ngZone = TestBed.inject(NgZone);
});
it('should be created', () => {
});
it('should prevent user if not loggedIn and redirect to login page', fakeAsync(() => {
- const router = TestBed.get(Router);
+ const router = TestBed.inject(Router);
ngZone.run(() => {
expect(service.canActivate()).toBe(false);
});
});
beforeEach(() => {
- service = TestBed.get(ChangePasswordGuardService);
- authStorageService = TestBed.get(AuthStorageService);
- ngZone = TestBed.get(NgZone);
+ service = TestBed.inject(ChangePasswordGuardService);
+ authStorageService = TestBed.inject(AuthStorageService);
+ ngZone = TestBed.inject(NgZone);
});
it('should be created', () => {
spyOn(authStorageService, 'isLoggedIn').and.returnValue(true);
spyOn(authStorageService, 'isSSO').and.returnValue(false);
spyOn(authStorageService, 'getPwdUpdateRequired').and.returnValue(true);
- const router = TestBed.get(Router);
+ const router = TestBed.inject(Router);
ngZone.run(() => {
expect(service.canActivate()).toBeFalsy();
});
});
it('should be created', () => {
- const service: DepCheckerService = TestBed.get(DepCheckerService);
+ const service: DepCheckerService = TestBed.inject(DepCheckerService);
expect(service).toBeTruthy();
});
});
beforeEach(() => {
TestBed.configureTestingModule({});
- service = TestBed.get(DeviceService);
+ service = TestBed.inject(DeviceService);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(FeatureTogglesGuardService);
- fakeFeatureTogglesService = TestBed.get(FeatureTogglesService);
- ngZone = TestBed.get(NgZone);
- router = TestBed.get(Router);
+ service = TestBed.inject(FeatureTogglesGuardService);
+ fakeFeatureTogglesService = TestBed.inject(FeatureTogglesService);
+ ngZone = TestBed.inject(NgZone);
+ router = TestBed.inject(Router);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(FeatureTogglesService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(FeatureTogglesService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(LanguageService);
- httpTesting = TestBed.get(HttpTestingController);
+ service = TestBed.inject(LanguageService);
+ httpTesting = TestBed.inject(HttpTestingController);
});
afterEach(() => {
});
beforeEach(() => {
- service = TestBed.get(ModuleStatusGuardService);
- httpClient = TestBed.get(HttpClient);
- router = TestBed.get(Router);
+ service = TestBed.inject(ModuleStatusGuardService);
+ httpClient = TestBed.inject(HttpClient);
+ router = TestBed.inject(Router);
route = new ActivatedRouteSnapshot();
route.url = [];
route.data = {
redirectTo: '/foo'
}
};
- ngZone = TestBed.get(NgZone);
+ ngZone = TestBed.inject(NgZone);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(NoSsoGuardService);
- authStorageService = TestBed.get(AuthStorageService);
- ngZone = TestBed.get(NgZone);
- router = TestBed.get(Router);
+ service = TestBed.inject(NoSsoGuardService);
+ authStorageService = TestBed.inject(AuthStorageService);
+ ngZone = TestBed.inject(NgZone);
+ router = TestBed.inject(Router);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(NotificationService);
+ service = TestBed.inject(NotificationService);
service.removeAll();
});
spyOn(global, 'Date').and.returnValue(baseTime);
spyOn(window, 'setTimeout').and.callFake((fn) => fn());
- toastr = TestBed.get(ToastrService);
+ toastr = TestBed.inject(ToastrService);
// spyOn needs to know the methods before spying and can't read the array for clarification
['error', 'info', 'success'].forEach((method: 'error' | 'info' | 'success') =>
spyOn(toastr, method).and.stub()
});
beforeEach(() => {
- service = TestBed.get(PasswordPolicyService);
- settingsService = TestBed.get(SettingsService);
+ service = TestBed.inject(PasswordPolicyService);
+ settingsService = TestBed.inject(SettingsService);
settingsService['settings'] = {};
});
beforeEach(() => {
prometheus = new PrometheusHelper();
- service = TestBed.get(PrometheusAlertFormatter);
- notificationService = TestBed.get(NotificationService);
+ service = TestBed.inject(PrometheusAlertFormatter);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
});
});
it('should create', () => {
- expect(TestBed.get(PrometheusAlertService)).toBeTruthy();
+ expect(TestBed.inject(PrometheusAlertService)).toBeTruthy();
});
describe('test failing status codes and verify disabling of the alertmanager', () => {
const isDisabledByStatusCode = (statusCode: number, expectedStatus: boolean, done: any) => {
- service = TestBed.get(PrometheusAlertService);
- prometheusService = TestBed.get(PrometheusService);
+ service = TestBed.inject(PrometheusAlertService);
+ prometheusService = TestBed.inject(PrometheusService);
spyOn(prometheusService, 'ifAlertmanagerConfigured').and.callFake((fn) => fn());
spyOn(prometheusService, 'getAlerts').and.returnValue(
Observable.create((observer: any) => observer.error({ status: statusCode, error: {} }))
});
it('should flatten the response of getRules()', () => {
- service = TestBed.get(PrometheusAlertService);
- prometheusService = TestBed.get(PrometheusService);
+ service = TestBed.inject(PrometheusAlertService);
+ prometheusService = TestBed.inject(PrometheusService);
spyOn(service['prometheusService'], 'ifPrometheusConfigured').and.callFake((fn) => fn());
spyOn(prometheusService, 'getRules').and.returnValue(
describe('refresh', () => {
beforeEach(() => {
- service = TestBed.get(PrometheusAlertService);
+ service = TestBed.inject(PrometheusAlertService);
service['alerts'] = [];
service['canAlertsBeNotified'] = false;
spyOn(window, 'setTimeout').and.callFake((fn: Function) => fn());
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
spyOn(notificationService, 'show').and.stub();
- prometheusService = TestBed.get(PrometheusService);
+ prometheusService = TestBed.inject(PrometheusService);
spyOn(prometheusService, 'ifAlertmanagerConfigured').and.callFake((fn) => fn());
spyOn(prometheusService, 'getAlerts').and.callFake(() => of(alerts));
beforeEach(() => {
prometheus = new PrometheusHelper();
- service = TestBed.get(PrometheusNotificationService);
+ service = TestBed.inject(PrometheusNotificationService);
service['notifications'] = [];
- notificationService = TestBed.get(NotificationService);
+ notificationService = TestBed.inject(NotificationService);
shown = [];
spyOn(notificationService, 'show').and.callThrough();
spyOn(notificationService, 'save').and.callFake((n) => shown.push(n));
spyOn(window, 'setTimeout').and.callFake((fn: Function) => fn());
- prometheusService = TestBed.get(PrometheusService);
+ prometheusService = TestBed.inject(PrometheusService);
getNotificationSinceMock = () => of(notifications);
spyOn(prometheusService, 'getNotifications').and.callFake(() => getNotificationSinceMock());
beforeEach(() => {
prometheus = new PrometheusHelper();
- service = TestBed.get(PrometheusSilenceMatcherService);
+ service = TestBed.inject(PrometheusSilenceMatcherService);
rules = [
prometheus.createRule('alert0', 'someSeverity', [prometheus.createAlert('alert0')]),
prometheus.createRule('alert1', 'someSeverity', []),
});
beforeEach(() => {
- service = TestBed.get(RbdConfigurationService);
+ service = TestBed.inject(RbdConfigurationService);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(RefreshIntervalService);
+ service = TestBed.inject(RefreshIntervalService);
});
it('should be created', () => {
it('should initial private interval time right', () => {
sessionStorage.setItem('dashboard_interval', '10000');
- const ngZone = TestBed.get(NgZone);
+ const ngZone = TestBed.inject(NgZone);
service = new RefreshIntervalService(ngZone);
expect(service.getRefreshInterval()).toBe(10000);
});
});
beforeEach(() => {
- summaryService = TestBed.get(SummaryService);
- authStorageService = TestBed.get(AuthStorageService);
+ summaryService = TestBed.inject(SummaryService);
+ authStorageService = TestBed.inject(AuthStorageService);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(TaskListService);
- summaryService = TestBed.get(SummaryService);
- taskMessageService = TestBed.get(TaskMessageService);
+ service = TestBed.inject(TaskListService);
+ summaryService = TestBed.inject(SummaryService);
+ taskMessageService = TestBed.inject(TaskMessageService);
summaryService['summaryDataSource'].next({ executing_tasks: [] });
taskMessageService.messages['test/create'] = taskMessageService.messages['rbd/create'];
});
beforeEach(() => {
- taskManagerService = TestBed.get(TaskManagerService);
- summaryService = TestBed.get(SummaryService);
+ taskManagerService = TestBed.inject(TaskManagerService);
+ summaryService = TestBed.inject(SummaryService);
called = false;
taskManagerService.subscribe('foo', {}, () => (called = true));
});
});
beforeEach(() => {
- service = TestBed.get(TaskMessageService);
+ service = TestBed.inject(TaskMessageService);
finishedTask = new FinishedTask();
finishedTask.duration = 30;
});
beforeEach(() => {
passed = false;
- notify = TestBed.get(NotificationService);
- summaryService = TestBed.get(SummaryService);
+ notify = TestBed.inject(NotificationService);
+ summaryService = TestBed.inject(SummaryService);
spyOn(notify, 'show');
spyOn(notify, 'notifyTask').and.stub();
spyOn(service, '_handleExecutingTasks').and.callThrough();
});
it('should call notifyTask if asynchronous task would have been finished', () => {
- const taskManager = TestBed.get(TaskManagerService);
+ const taskManager = TestBed.inject(TaskManagerService);
spyOn(taskManager, 'subscribe').and.callFake((_name, _metadata, onTaskFinished) => {
onTaskFinished();
});
});
beforeEach(() => {
- service = TestBed.get(TextToDownloadService);
+ service = TestBed.inject(TextToDownloadService);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(TimeDiffService);
+ service = TestBed.inject(TimeDiffService);
});
it('should be created', () => {
});
beforeEach(() => {
- service = TestBed.get(TimerService);
+ service = TestBed.inject(TimerService);
receivedData = [];
});
+import { ActivatedRoute } from '@angular/router';
+
import { ReplaySubject } from 'rxjs';
/**
* An ActivateRoute test double with a `params` observable.
* Use the `setParams()` method to add the next `params` value.
*/
-export class ActivatedRouteStub {
+export class ActivatedRouteStub extends ActivatedRoute {
// Use a ReplaySubject to share previous values with subscribers
// and pump new values into the `params` observable
private subject = new ReplaySubject<object>();
constructor(initialParams?: object) {
+ super();
this.setParams(initialParams);
}